Skip to content

Commit

Permalink
Unknown messages support - add enable/disable option to Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
danilvalov committed Apr 23, 2024
1 parent 59c6849 commit ae63a3b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
8 changes: 8 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
"help_text": "Generated token to validate incoming requests from AWS SNS.",
"placeholder": "",
"default": null
},
{
"key": "EnableUnknownTypeMessages",
"display_name": "Enable unkown type notifications support:",
"type": "bool",
"help_text": "If the AWS SNS plugin does not support a particular type of SNS notifications, it displays those notifications as formatted JSON or plain text.",
"placeholder": "",
"default": false
}
]
}
Expand Down
7 changes: 4 additions & 3 deletions server/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
// If you add non-reference types to your configuration struct, be sure to rewrite Clone as a deep
// copy appropriate for your types.
type configuration struct {
TeamChannel string
AllowedUserIds string
Token string
TeamChannel string
AllowedUserIds string
Token string
EnableUnknownTypeMessages bool
}

// Clone shallow copies the configuration. Your implementation may require a deep copy if
Expand Down
4 changes: 3 additions & 1 deletion server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ func (p *Plugin) handleNotification(body io.Reader, channel *TeamChannel) {
return
}

p.sendPostNotification(p.createSNSUnknownTypeMessage(notification.Subject, notification.Message), channel)
if p.configuration.EnableUnknownTypeMessages {
p.sendPostNotification(p.createSNSUnknownTypeMessage(notification.Subject, notification.Message), channel)
}
}

func (p *Plugin) sendPostNotification(attachment model.SlackAttachment, channel *TeamChannel) {
Expand Down

0 comments on commit ae63a3b

Please sign in to comment.