Update post types and include system removals in skip logic (mattermost) (#2125)

This commit is contained in:
Neil Hanlon 2024-05-23 17:58:58 -04:00 committed by GitHub
parent fa147c076f
commit 6b528ffa4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -171,12 +171,24 @@ func (b *Bmattermost) sendWebhook(msg config.Message) (string, error) {
} }
// skipMessages returns true if this message should not be handled // skipMessages returns true if this message should not be handled
//
//nolint:gocyclo,cyclop //nolint:gocyclo,cyclop
func (b *Bmattermost) skipMessage(message *matterclient.Message) bool { func (b *Bmattermost) skipMessage(message *matterclient.Message) bool {
// Handle join/leave // Handle join/leave
if message.Type == "system_join_leave" || skipJoinMessageTypes := map[string]struct{}{
message.Type == "system_join_channel" || "system_join_leave": {}, //deprecated for system_add_to_channel
message.Type == "system_leave_channel" { "system_leave_channel": {}, //deprecated for system_remove_from_channel
"system_join_channel": {},
"system_add_to_channel": {},
"system_remove_from_channel": {},
"system_add_to_team": {},
"system_remove_from_team": {},
}
// dirty hack to efficiently check if this element is in the map without writing a contains func
// can be replaced with native slice.contains with go 1.21
if _, ok := skipJoinMessageTypes[message.Type]; ok {
if b.GetBool("nosendjoinpart") { if b.GetBool("nosendjoinpart") {
return true return true
} }