Skip to content

Commit

Permalink
Merge pull request #19 from gobridge/disable_broadcast
Browse files Browse the repository at this point in the history
Unlearn replying to thread_broadcast messages with its own broadcast
  • Loading branch information
ardan-bkennedy authored Sep 7, 2020
2 parents ddbae49 + 4e89ec8 commit 20776b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 11 additions & 0 deletions handler/message_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ func shouldDiscard(m *slackevents.MessageEvent) (string, bool) {
return fmt.Sprintf("message has subtype %s", m.SubType), true
}

// TODO(theckman): as of now the bot is unable to recognize whether a
// thread_broadcast message was from itself or not. We need to add support
// for parsing the root subkey of the thread_broadcast message event:
// https://api.slack.com/events/message/thread_broadcast, because that's the
// user we care about.
//
// Once that's added we should discard thread_broadcast messages from
// ourselves.
//
// Also, see related TODO in responder.go.

tss := strings.Split(m.TimeStamp, ".")[0]

// we assume this is a well-formed message
Expand Down
11 changes: 8 additions & 3 deletions handler/responder.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,14 @@ func (r response) respond(ctx context.Context, mentionUser, useMentions, ephemer

// if it's a command that was triggered in a shared thread reply
// we should share our reply with the channel too
if len(subType) > 0 && subType == "thread_broadcast" {
opts = append(opts, slack.MsgOptionBroadcast())
}
//
// TODO(theckman): re-enable this functionality once gopher is able to
// recognize thread_broadcast messages from itself. See TODO in
// message_actions.go for more context.
//
// if len(subType) > 0 && subType == "thread_broadcast" {
// opts = append(opts, slack.MsgOptionBroadcast())
// }

if len(attachments) > 0 {
opts = append(opts, slack.MsgOptionAttachments(attachments...))
Expand Down

0 comments on commit 20776b4

Please sign in to comment.