Skip to content

Commit

Permalink
Don't suppress @user incorrectly in non-ephemeral msg
Browse files Browse the repository at this point in the history
  • Loading branch information
parsley42 committed Dec 2, 2024
1 parent fdf16fb commit cc0ffc8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions connectors/slack/connectorMethods.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (s *slackConnector) SetUserMap(umap map[string]string) {

// SendProtocolChannelMessage sends a message to a channel
func (s *slackConnector) SendProtocolChannelThreadMessage(ch, thr, msg string, f robot.MessageFormat, msgObject *robot.ConnectorMessage) (ret robot.RetVal) {
msgs := s.slackifyMessage("", msg, f, msgObject)
msgs := s.slackifyMessage("", "", msg, f, msgObject)
if chanID, ok := s.ExtractID(ch); ok {
s.sendMessages(msgs, "", chanID, thr, f, msgObject)
return
Expand Down Expand Up @@ -228,7 +228,7 @@ func (s *slackConnector) SendProtocolUserChannelThreadMessage(uid, u, ch, thr, m
}
// This gets converted to <@userID> in slackifyMessage
prefix := "<@" + userID + ">: "
msgs := s.slackifyMessage(prefix, msg, f, msgObject)
msgs := s.slackifyMessage(userID, prefix, msg, f, msgObject)
s.sendMessages(msgs, userID, chanID, thr, f, msgObject)
return robot.Ok
}
Expand Down Expand Up @@ -262,7 +262,7 @@ func (s *slackConnector) SendProtocolUserMessage(u string, msg string, f robot.M
}
userIMchanstr = userIMchan.Conversation.ID
}
msgs := s.slackifyMessage("", msg, f, msgObject)
msgs := s.slackifyMessage(userID, "", msg, f, msgObject)
s.sendMessages(msgs, "", userIMchanstr, "", f, msgObject)
return robot.Ok
}
Expand Down
4 changes: 2 additions & 2 deletions connectors/slack/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (s *slackConnector) processRawMessage(msg string) string {

// slackifyMessage replaces @username with the slack-internal representation, handles escaping,
// takes care of formatting, and segments the message if needed.
func (s *slackConnector) slackifyMessage(prefix, msg string, f robot.MessageFormat, msgObject *robot.ConnectorMessage) []string {
func (s *slackConnector) slackifyMessage(targetUserID, prefix, msg string, f robot.MessageFormat, msgObject *robot.ConnectorMessage) []string {
maxSize := slack.MaxMessageTextLength - 490

if f == robot.Raw {
Expand All @@ -152,7 +152,7 @@ func (s *slackConnector) slackifyMessage(prefix, msg string, f robot.MessageForm
}
}
mtype := getMsgType(msgObject)
if len(prefix) > 0 && mtype != msgSlashCmd {
if len(prefix) > 0 && (mtype != msgSlashCmd || (targetUserID != msgObject.UserID)) {
msg = prefix + msg
}
if f == robot.Fixed {
Expand Down

0 comments on commit cc0ffc8

Please sign in to comment.