summaryrefslogtreecommitdiffstats
path: root/bridge/slack/handlers.go
diff options
context:
space:
mode:
authorAndy <flashgame73@gmail.com>2022-05-10 00:56:19 +0400
committerGitHub <noreply@github.com>2022-05-09 22:56:19 +0200
commit700b95546b4fbc4bbd094ab1804406c13634d7e2 (patch)
tree2b86658952deb8f7761fd276e89164ff3afd1526 /bridge/slack/handlers.go
parent2fa96ec0ed5d78357a11dee158cac9a9e6d7090d (diff)
downloadmatterbridge-msglm-700b95546b4fbc4bbd094ab1804406c13634d7e2.tar.gz
matterbridge-msglm-700b95546b4fbc4bbd094ab1804406c13634d7e2.tar.bz2
matterbridge-msglm-700b95546b4fbc4bbd094ab1804406c13634d7e2.zip
Improve Slack attachments formatting (slack) (#1807)
* Improve Slack attachments formatting (slack) * Add TitleLink * Add Footer * Fix linter issues
Diffstat (limited to 'bridge/slack/handlers.go')
-rw-r--r--bridge/slack/handlers.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/bridge/slack/handlers.go b/bridge/slack/handlers.go
index c469b9a5..225931d4 100644
--- a/bridge/slack/handlers.go
+++ b/bridge/slack/handlers.go
@@ -282,6 +282,13 @@ func (b *Bslack) handleStatusEvent(ev *slack.MessageEvent, rmsg *config.Message)
return false
}
+func getMessageTitle(attach *slack.Attachment) string {
+ if attach.TitleLink != "" {
+ return fmt.Sprintf("[%s](%s)\n", attach.Title, attach.TitleLink)
+ }
+ return attach.Title
+}
+
func (b *Bslack) handleAttachments(ev *slack.MessageEvent, rmsg *config.Message) {
// File comments are set by the system (because there is no username given).
if ev.SubType == sFileComment {
@@ -290,12 +297,15 @@ func (b *Bslack) handleAttachments(ev *slack.MessageEvent, rmsg *config.Message)
// See if we have some text in the attachments.
if rmsg.Text == "" {
- for _, attach := range ev.Attachments {
+ for i, attach := range ev.Attachments {
if attach.Text != "" {
if attach.Title != "" {
- rmsg.Text = attach.Title + "\n"
+ rmsg.Text = getMessageTitle(&ev.Attachments[i])
}
rmsg.Text += attach.Text
+ if attach.Footer != "" {
+ rmsg.Text += "\n\n" + attach.Footer
+ }
} else {
rmsg.Text = attach.Fallback
}