Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(slack): add thread/reply support #182

Merged
merged 1 commit into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions pkg/services/slack/slack_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ package slack

import (
"fmt"
"net/url"
"strings"

"github.com/containrrr/shoutrrr/pkg/format"
"github.com/containrrr/shoutrrr/pkg/services/standard"
"github.com/containrrr/shoutrrr/pkg/types"
"net/url"
"strings"
)

// Config for the slack service
type Config struct {
standard.EnumlessConfig
BotName string `default:"" optional:"" url:"user" desc:"Bot name (uses default if empty)"`
Token []string `desc:"Webhook token parts" url:"host,path1,path2"`
Color string `key:"color" optional:"" desc:"Message left-hand border color"`
Title string `key:"title" optional:"" desc:"Prepended text above the message"`
BotName string `default:"" optional:"" url:"user" desc:"Bot name (uses default if empty)"`
Token []string `desc:"Webhook token parts" url:"host,path1,path2"`
Color string `key:"color" optional:"" desc:"Message left-hand border color"`
Title string `key:"title" optional:"" desc:"Prepended text above the message"`
ThreadTS string `key:"thread_ts" optional:"" desc:"ts value of the parent message (to send message as reply in thread)"`
}

// GetURL returns a URL representation of it's current field values
Expand Down
2 changes: 2 additions & 0 deletions pkg/services/slack/slack_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type JSON struct {
BotName string `json:"username,omitempty"`
Blocks []block `json:"blocks,omitempty"`
Attachments []attachment `json:"attachments,omitempty"`
ThreadTS string `json:"thread_ts,omitempty"`
}

type block struct {
Expand Down Expand Up @@ -52,6 +53,7 @@ func CreateJSONPayload(config *Config, message string) ([]byte, error) {

return json.Marshal(
JSON{
ThreadTS: config.ThreadTS,
Text: config.Title,
BotName: config.BotName,
Attachments: atts,
Expand Down