Skip to content

Commit

Permalink
MM-58344: style notifications (#667)
Browse files Browse the repository at this point in the history
* updated styling

* rewrite TestHandleCreatedActivity, add notifications
  • Loading branch information
lieut-data authored May 23, 2024
1 parent 35c0bc2 commit 6cfdd81
Show file tree
Hide file tree
Showing 4 changed files with 814 additions and 534 deletions.
26 changes: 26 additions & 0 deletions server/bot_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,29 @@ func (p *Plugin) makeWelcomeMessageWithNotificationActionPost() *model.Post {
},
}
}

// notifyMessage sends the given receipient a notification of a chat received on Teams.
func (p *Plugin) notifyChat(recipientUserID string, actorDisplayName string, chatSize int, chatLink string, message string) {
var preamble string

if chatSize <= 1 {
return
} else if chatSize == 2 {
preamble = fmt.Sprintf("%s messaged you in MS Teams:", actorDisplayName)
} else if chatSize == 3 {
preamble = fmt.Sprintf("%s messaged you and 1 other user in MS Teams:", actorDisplayName)
} else {
preamble = fmt.Sprintf("%s messaged you and %d other users in MS Teams:", actorDisplayName, chatSize-2)
}

message = "> " + strings.ReplaceAll(message, "\n", "\n>")

formattedMessage := fmt.Sprintf(`%s
%s
**[Respond in Microsoft Teams ↗️](%s)**`, preamble, message, chatLink)

if err := p.botSendDirectMessage(recipientUserID, formattedMessage); err != nil {
p.GetAPI().LogWarn("Failed to send notification message", "user_id", recipientUserID, "error", err)
}
}
Loading

0 comments on commit 6cfdd81

Please sign in to comment.