From ae63a3b3a6e0bf5fb1eda63f5a9e724a6e725de9 Mon Sep 17 00:00:00 2001 From: Danil Valov Date: Wed, 24 Apr 2024 00:49:46 +0300 Subject: [PATCH] Unknown messages support - add enable/disable option to Settings --- plugin.json | 8 ++++++++ server/configuration.go | 7 ++++--- server/plugin.go | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/plugin.json b/plugin.json index 16bf974..112660f 100644 --- a/plugin.json +++ b/plugin.json @@ -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 } ] } diff --git a/server/configuration.go b/server/configuration.go index a967c43..f2a9500 100644 --- a/server/configuration.go +++ b/server/configuration.go @@ -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 diff --git a/server/plugin.go b/server/plugin.go index cc43325..1302b67 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -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) {