Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for message attachments #574

Open
hloeung opened this issue Feb 14, 2024 · 0 comments · May be fixed by #575
Open

Add support for message attachments #574

hloeung opened this issue Feb 14, 2024 · 0 comments · May be fixed by #575
Assignees

Comments

@hloeung
Copy link
Collaborator

hloeung commented Feb 14, 2024

This is documented in https://developers.mattermost.com/integrate/reference/message-attachments/

It is used in various integrations such as that from Flux - https://github.com/fluxcd/notification-controller/blob/main/internal/notifier/slack.go

I think it would be nice to add support for it. Messages from Flux CD uses color "good" and "danger" e.g.

[2024-02-13T23:47:24Z] DEBUG matterclient: WsReceiver event: &model.WebSocketEvent{event:"posted", data:map[string]interface {}{"channel_display_name":"IS Notifications", "channel_name":"is-notifications", "channel_type":"P", "post":"{\"id\":\"pwmaszqpy7re9npgpr687ansua\",\"create_at\":1707868043816,\"update_at\":1707868043816,\"edit_at\":0,\"delete_at\":0,\"is_pinned\":false,\"user_id\":\"55n7z5xprfrj5qza7m1rqj7zpe\",\"channel_id\":\"s1e989b14b8g3yhkuco8dnb5qy\",\"root_id\":\"\",\"original_id\":\"\",\"message\":\"\",\"type\":\"slack_attachment\",\"props\":{\"attachments\":[{\"id\":0,\"fallback\":\"\",\"color\":\"danger\",\"pretext\":\"\",\"author_name\":\"terraform/prod-temporal.fluxsystem\",\"author_link\":\"\",\"author_icon\":\"\",\"title\":\"\",\"title_link\":\"\",\"text\":\"Drift detected.\\n\\nNote:...\\n\",\"fields\":[{\"title\":\"revision\",\"value\":\"main@sha1:a0f7095d8d855e988337b7cd18432c17d3d0a70f\",\"short\":false},{\"title\":\"summary\",\"value\":\"Terraform event detected\",\"short\":false}],\"image_url\":\"\",\"thumb_url\":\"\",\"footer\":\"\",\"footer_icon\":\"\",\"ts\":null}],\"from_bot\":\"true\",\"from_webhook\":\"true\",\"webhook_display_name\":\"IS Flux Notifications\"},\"hashtags\":\"\",\"pending_post_id\":\"\",\"reply_count\":0,\"last_reply_at\":0,\"participants\":null,\"metadata\":{\"embeds\": [{\"type\":\"message_attachment\"}]}}", "sender_name":"@is-flux-bot", "set_online":false, "team_id":"sqmc4sz45prypmkfctwynm5yjr"}, broadcast:(*model.WebsocketBroadcast)(0xc0002ee040), sequence:3334, precomputedJSON: *model.precomputedWebSocketEventJSON)(nil)}

And:

[2024-02-13T23:47:31Z] DEBUG matterclient: WsReceiver event: &model.WebSocketEvent{event:"posted", data:map[string]interface {}{"channel_display_name":"IS Notifications", "channel_name":"is-notifications", "channel_type":"P", "post":"{\"id\":\"tacyqhdk1jdhtg5zgornn7tnay\",\"create_at\":1707868050914,\"update_at\":1707868050914,\"edit_at\":0,\"delete_at\":0,\"is_pinned\":false,\"user_id\":\"55n7z5xprfrj5qza7m1rqj7zpe\",\"channel_id\":\"s1e989b14b8g3yhkuco8dnb5qy\",\"root_id\":\"\",\"original_id\":\"\",\"message\":\"\",\"type\":\"slack_attachment\",\"props\":{\"attachments\":[{\"id\":0,\"fallback\":\"\",\"color\":\"good\",\"pretext\":\"\",\"author_name\":\"terraform/prod-temporal.flux-system\",\"author_link\":\"\",\"author_icon\":\"\",\"title\":\"\",\"title_link\":\"\",\"text\":\"Applied successfully\",\"fields\":[{\"title\":\"revision\",\"value\":\"main@sha1:a0f7095d8d855e988337b7cd18432c17d3d0a70f\",\"short\":false},{\"title\":\"summary\",\"value\":\"Terraform event detected\",\"short\":false}],\"image_url\":\"\",\"thumb_url\":\"\",\"footer\":\"\",\"footer_icon\":\"\",\"ts\":null}],\"from_bot\":\"true\",\"from_webhook\":\"true\",\"webhook_display_name\":\"IS Flux Notifications\"},\"hashtags\":\"\",\"pending_post_id\":\"\",\"reply_count\":0,\"last_reply_at\":0,\"participants\":null,\"metadata\":{\"embeds\":[{\"type\":\"message_attachment\"}]}}", "sender_name":"@is-flux-bot", "set_online":false, "team_id":"sqmc4sz45prypmkfctwynm5yjr"}, broadcast:(*model.WebsocketBroadcast)(0xc00022a3c0), sequence:3337, precomputedJSON:(*model.precomputedWebSocketEventJSON)(nil)}

@hloeung hloeung self-assigned this Feb 14, 2024
@hloeung hloeung linked a pull request Feb 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant