mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-11 13:06:28 +00:00
Improve Slack attachments formatting (slack) (#1807)
* Improve Slack attachments formatting (slack) * Add TitleLink * Add Footer * Fix linter issues
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user