42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.59k stars 614 forks source link

Bot messages not relayed properly between slacks #2054

Open LCloud-Tech-Account opened 1 year ago

LCloud-Tech-Account commented 1 year ago

Describe the bug We have two slack channels connected via matterbridge with each other, and also a mattermost workspaceq. The channels we bridged also contain other bots. When a different bot that is also in this channel posts message it is relayed properly to the mattermost instance, but not to the other Slack channel. When user posts it works properly in both ways.

To Reproduce link two slack workspaces via matterbridge instance

Expected behavior Bot messages are relayed to both matterbridge and the secondary Slack workspace.

Screenshots/debug logs Slack bot message: image

The same message in mattermost: image

Slightly edited logs regarding this message:

time="2023-05-31T20:35:44Z" level=debug msg="<= Sending message from lcloud_alarms on slack.lcloud to gateway" func=handleSlack file="bridge/slack/handlers.go:32" prefix=slack

time="2023-05-31T20:35:44Z" level=debug msg="<= Message is &config.Message{Text:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*Triggered*\n\nAlarm State: **ALARM**\nAlarm State Changed: **2023-05-31T20:35:29.954+0000**\nAWS AccountId: **XXXXXXXXXXXX**\nAWS Region: *XXXXXXXXXXXXXXX**\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", Channel:"ID:111111111", Username:"lcloud_alarms", UserID:"XXXXXXXXXX", Avatar:"https://avatars.slack-edge.com/2020-12-21/1590615258595_3c9eecd2a21e9f3ab5ae_48.png", Account:"slack.lcloud", Event:"", Protocol:"slack", Gateway:"", ParentID:"", Timestamp:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), ID:"1685565343.817259", Extra:map[string][]interface {}{"slack_attachment":[]interface {}{[]slack.Attachment{slack.Attachment{Color:"DD0000", Fallback:"", CallbackID:"", ID:1, AuthorID:"", AuthorName:"", AuthorSubname:"", AuthorLink:"", AuthorIcon:"", Title:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", TitleLink:"", Pretext:"", Text:"*Triggered*\n\nAlarm State: *ALARM*\nAlarm State Changed: *2023-05-31T20:35:29.954+0000*\nAWS AccountId: *XXXXXXXXXXXX*\nAWS Region: XXXXXXXXXXXXXXX*\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", ImageURL:"", ThumbURL:"", ServiceName:"", ServiceIcon:"", FromURL:"", OriginalURL:"", Fields:[]slack.AttachmentField(nil), Actions:[]slack.AttachmentAction(nil), MarkdownIn:[]string{"pretext", "text"}, Blocks:slack.Blocks{BlockSet:[]slack.Block(nil)}, Footer:"", FooterIcon:"", Ts:""}}}}}" func=handleSlack file="bridge/slack/handlers.go:45" prefix=slack

time="2023-05-31T20:35:44Z" level=debug msg="=> Sending config.Message{Text:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*Triggered*\n\nAlarm State: **ALARM**\nAlarm State Changed: **2023-05-31T20:35:29.954+0000**\nAWS AccountId: **XXXXXXXXXXXX**\nAWS Region: *XXXXXXXXXXXXXXX**\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", Channel:"ID:111111111", Username:"lcloud_alarms", UserID:"XXXXXXXXXX", Avatar:"https://avatars.slack-edge.com/2020-12-21/1590615258595_3c9eecd2a21e9f3ab5ae_48.png", Account:"slack.lcloud", Event:"", Protocol:"slack", Gateway:"testczymatterbridgeprzesylaalerty", ParentID:"", Timestamp:time.Date(2023, time.May, 31, 20, 35, 44, 5220295, time.Local), ID:"1685565343.817259", Extra:map[string][]interface {}{"slack_attachment":[]interface {}{[]slack.Attachment{slack.Attachment{Color:"DD0000", Fallback:"", CallbackID:"", ID:1, AuthorID:"", AuthorName:"", AuthorSubname:"", AuthorLink:"", AuthorIcon:"", Title:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", TitleLink:"", Pretext:"", Text:"*Triggered*\n\nAlarm State: *ALARM*\nAlarm State Changed: *2023-05-31T20:35:29.954+0000*\nAWS AccountId: *XXXXXXXXXXXX*\nAWS Region: XXXXXXXXXXXXXXX*\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", ImageURL:"", ThumbURL:"", ServiceName:"", ServiceIcon:"", FromURL:"", OriginalURL:"", Fields:[]slack.AttachmentField(nil), Actions:[]slack.AttachmentAction(nil), MarkdownIn:[]string{"pretext", "text"}, Blocks:slack.Blocks{BlockSet:[]slack.Block(nil)}, Footer:"", FooterIcon:"", Ts:""}}}}} from slack.lcloud (ID:111111111) to slack.lcloud (ID:22222222222)" func=SendMessage file="gateway/gateway.go:499" prefix=gateway

time="2023-05-31T20:35:44Z" level=debug msg="=> Receiving config.Message{Text:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*Triggered*\n\nAlarm State: **ALARM**\nAlarm State Changed: **2023-05-31T20:35:29.954+0000**\nAWS AccountId: **XXXXXXXXXXXX**\nAWS Region: *XXXXXXXXXXXXXXX**\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", Channel:"ID:22222222222", Username:"<lcloud_alarms> ", UserID:"XXXXXXXXXX", Avatar:"https://avatars.slack-edge.com/2020-12-21/1590615258595_3c9eecd2a21e9f3ab5ae_48.png", Account:"slack.lcloud", Event:"", Protocol:"slack", Gateway:"testczymatterbridgeprzesylaalerty", ParentID:"", Timestamp:time.Date(2023, time.May, 31, 20, 35, 44, 5220295, time.Local), ID:"", Extra:map[string][]interface {}{"slack_attachment":[]interface {}{[]slack.Attachment{slack.Attachment{Color:"DD0000", Fallback:"", CallbackID:"", ID:1, AuthorID:"", AuthorName:"", AuthorSubname:"", AuthorLink:"", AuthorIcon:"", Title:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", TitleLink:"", Pretext:"", Text:"*Triggered*\n\nAlarm State: *ALARM*\nAlarm State Changed: *2023-05-31T20:35:29.954+0000*\nAWS AccountId: *XXXXXXXXXXXX*\nAWS Region: XXXXXXXXXXXXXXX*\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", ImageURL:"", ThumbURL:"", ServiceName:"", ServiceIcon:"", FromURL:"", OriginalURL:"", Fields:[]slack.AttachmentField(nil), Actions:[]slack.AttachmentAction(nil), MarkdownIn:[]string{"pretext", "text"}, Blocks:slack.Blocks{BlockSet:[]slack.Block(nil)}, Footer:"", FooterIcon:"", Ts:""}}}}}" func=Send file="bridge/slack/slack.go:196" prefix=slack

time="2023-05-31T20:35:44Z" level=debug msg="=> Send from slack.lcloud (ID:111111111) to slack.lcloud (ID:22222222222) took 184.023µs" func=func1 file="gateway/gateway.go:508" prefix=gateway

time="2023-05-31T20:35:44Z" level=debug msg="=> Sending config.Message{Text:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*Triggered*\n\nAlarm State: **ALARM**\nAlarm State Changed: **2023-05-31T20:35:29.954+0000**\nAWS AccountId: **XXXXXXXXXXXX**\nAWS Region: *XXXXXXXXXXXXXXX**\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", Channel:"ID:111111111", Username:"lcloud_alarms", UserID:"XXXXXXXXXX", Avatar:"https://avatars.slack-edge.com/2020-12-21/1590615258595_3c9eecd2a21e9f3ab5ae_48.png", Account:"slack.lcloud", Event:"", Protocol:"slack", Gateway:"tmp-XXXXXX-notify", ParentID:"", Timestamp:time.Date(2023, time.May, 31, 20, 35, 44, 8967495, time.Local), ID:"1685565343.817259", Extra:map[string][]interface {}{"slack_attachment":[]interface {}{[]slack.Attachment{slack.Attachment{Color:"DD0000", Fallback:"", CallbackID:"", ID:1, AuthorID:"", AuthorName:"", AuthorSubname:"", AuthorLink:"", AuthorIcon:"", Title:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", TitleLink:"", Pretext:"", Text:"*Triggered*\n\nAlarm State: *ALARM*\nAlarm State Changed: *2023-05-31T20:35:29.954+0000*\nAWS AccountId: *XXXXXXXXXXXX*\nAWS Region: XXXXXXXXXXXXXXX*\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", ImageURL:"", ThumbURL:"", ServiceName:"", ServiceIcon:"", FromURL:"", OriginalURL:"", Fields:[]slack.AttachmentField(nil), Actions:[]slack.AttachmentAction(nil), MarkdownIn:[]string{"pretext", "text"}, Blocks:slack.Blocks{BlockSet:[]slack.Block(nil)}, Footer:"", FooterIcon:"", Ts:""}}}}} from slack.lcloud (ID:111111111) to mattermost.work (ID:xxxxxxxxxxxxxxxxxxxxxxxxxxx)" func=SendMessage file="gateway/gateway.go:499" prefix=gateway

time="2023-05-31T20:35:44Z" level=debug msg="=> Receiving config.Message{Text:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*Triggered*\n\nAlarm State: **ALARM**\nAlarm State Changed: **2023-05-31T20:35:29.954+0000**\nAWS AccountId: **XXXXXXXXXXXX**\nAWS Region: *XXXXXXXXXXXXXXX**\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", Channel:"ID:xxxxxxxxxxxxxxxxxxxxxxxxxxx", Username:"<lcloud_alarms> ", UserID:"XXXXXXXXXX", Avatar:"https://avatars.slack-edge.com/2020-12-21/1590615258595_3c9eecd2a21e9f3ab5ae_48.png", Account:"slack.lcloud", Event:"", Protocol:"slack", Gateway:"tmp-XXXXXX-notify", ParentID:"", Timestamp:time.Date(2023, time.May, 31, 20, 35, 44, 8967495, time.Local), ID:"", Extra:map[string][]interface {}{"slack_attachment":[]interface {}{[]slack.Attachment{slack.Attachment{Color:"DD0000", Fallback:"", CallbackID:"", ID:1, AuthorID:"", AuthorName:"", AuthorSubname:"", AuthorLink:"", AuthorIcon:"", Title:"(XXXXXX) ALARM (S5:Mon-Sun:00-24): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", TitleLink:"", Pretext:"", Text:"*Triggered*\n\nAlarm State: *ALARM*\nAlarm State Changed: *2023-05-31T20:35:29.954+0000*\nAWS AccountId: *XXXXXXXXXXXX*\nAWS Region: XXXXXXXXXXXXXXX*\n\nAlarm Description: Alarm for cloudwatch synthetics\n\nNew State Reason: Threshold Crossed: 1 datapoint [83.33333333333333 (31/05/23 19:35:00)] was less than the threshold (90.0).", ImageURL:"", ThumbURL:"", ServiceName:"", ServiceIcon:"", FromURL:"", OriginalURL:"", Fields:[]slack.AttachmentField(nil), Actions:[]slack.AttachmentAction(nil), MarkdownIn:[]string{"pretext", "text"}, Blocks:slack.Blocks{BlockSet:[]slack.Block(nil)}, Footer:"", FooterIcon:"", Ts:""}}}}}" func=Send file="bridge/mattermost/mattermost.go:126" prefix=mattermost

Environment (please complete the following information):

lcloud-EmlFTX commented 1 year ago

In above case, message is sent in attachments (this not the same as a file in the slack) In below line, "return" prevents posting the message: https://github.com/42wim/matterbridge/blob/v1.26.0/bridge/slack/slack.go#L335