Skip to content

Commit 4afae68

Browse files
committed
Unknown messages support - add enable/disable option to Settings
1 parent 59c6849 commit 4afae68

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

plugin.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
"help_text": "Generated token to validate incoming requests from AWS SNS.",
4444
"placeholder": "",
4545
"default": null
46+
},
47+
{
48+
"key": "EnableUnknownTypeMessages",
49+
"display_name": "Enable unknown type notifications support:",
50+
"type": "bool",
51+
"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.",
52+
"placeholder": "",
53+
"default": false
4654
}
4755
]
4856
}

server/configuration.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import (
1818
// If you add non-reference types to your configuration struct, be sure to rewrite Clone as a deep
1919
// copy appropriate for your types.
2020
type configuration struct {
21-
TeamChannel string
22-
AllowedUserIds string
23-
Token string
21+
TeamChannel string
22+
AllowedUserIds string
23+
Token string
24+
EnableUnknownTypeMessages bool
2425
}
2526

2627
// Clone shallow copies the configuration. Your implementation may require a deep copy if

server/plugin.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ func (p *Plugin) handleNotification(body io.Reader, channel *TeamChannel) {
269269
return
270270
}
271271

272-
p.sendPostNotification(p.createSNSUnknownTypeMessage(notification.Subject, notification.Message), channel)
272+
if p.configuration.EnableUnknownTypeMessages {
273+
p.sendPostNotification(p.createSNSUnknownTypeMessage(notification.Subject, notification.Message), channel)
274+
}
273275
}
274276

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

0 commit comments

Comments
 (0)