Skip to content

Commit

Permalink
feat(slack): add thread/reply support (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
parrasajad committed Jul 7, 2021
1 parent 64eda4a commit 8018a47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 8018a47

Please sign in to comment.