diff --git a/src/lib/addons/slack-app-definition.ts b/src/lib/addons/slack-app-definition.ts index 5df01d5c7bf1..fb2d5eb68d19 100644 --- a/src/lib/addons/slack-app-definition.ts +++ b/src/lib/addons/slack-app-definition.ts @@ -57,6 +57,14 @@ const slackAppDefinition: IAddonDefinition = { required: false, sensitive: false, }, + { + name: 'alwaysPostToDefault', + displayName: 'Always post to default channels', + description: `If set to 'true' or 'yes', the app will always post events to the default channels, even if the feature toggle has slack tags`, + type: 'text', + required: false, + sensitive: false, + }, ], events: [ FEATURE_CREATED, diff --git a/src/lib/addons/slack-app.ts b/src/lib/addons/slack-app.ts index bdf61c91d0ee..47f901de8cc3 100644 --- a/src/lib/addons/slack-app.ts +++ b/src/lib/addons/slack-app.ts @@ -23,6 +23,7 @@ import { IEvent } from '../types/events'; interface ISlackAppAddonParameters { accessToken: string; defaultChannels: string; + alwaysPostToDefault: string; } export default class SlackAppAddon extends Addon { @@ -45,16 +46,26 @@ export default class SlackAppAddon extends Addon { parameters: ISlackAppAddonParameters, ): Promise { try { - const { accessToken, defaultChannels } = parameters; + const { accessToken, defaultChannels, alwaysPostToDefault } = + parameters; if (!accessToken) { this.logger.warn('No access token provided.'); return; } - + let postToDefault = + alwaysPostToDefault === 'true' || alwaysPostToDefault === 'yes'; + this.logger.debug(`Post to default was set to ${postToDefault}`); const taggedChannels = this.findTaggedChannels(event); - const eventChannels = taggedChannels.length - ? taggedChannels - : this.getDefaultChannels(defaultChannels); + let eventChannels: string[]; + if (postToDefault) { + eventChannels = taggedChannels.concat( + this.getDefaultChannels(defaultChannels), + ); + } else { + eventChannels = taggedChannels.length + ? taggedChannels + : this.getDefaultChannels(defaultChannels); + } if (!eventChannels.length) { this.logger.debug(