From 6a1b09911731d4e23a0da042e61a4a270db786e4 Mon Sep 17 00:00:00 2001 From: grokdesigns Date: Mon, 4 Dec 2017 01:07:42 -0700 Subject: [PATCH] Added: Customize Slack Channel (#2308) (Fixes #2298) --- .../Notifications/Slack/Payloads/SlackPayload.cs | 2 ++ src/NzbDrone.Core/Notifications/Slack/Slack.cs | 6 ++++++ src/NzbDrone.Core/Notifications/Slack/SlackSettings.cs | 3 +++ 3 files changed, 11 insertions(+) diff --git a/src/NzbDrone.Core/Notifications/Slack/Payloads/SlackPayload.cs b/src/NzbDrone.Core/Notifications/Slack/Payloads/SlackPayload.cs index 09953c115..60509da36 100644 --- a/src/NzbDrone.Core/Notifications/Slack/Payloads/SlackPayload.cs +++ b/src/NzbDrone.Core/Notifications/Slack/Payloads/SlackPayload.cs @@ -15,6 +15,8 @@ namespace NzbDrone.Core.Notifications.Slack.Payloads [JsonProperty("icon_url")] public string IconUrl { get; set; } + public string Channel { get; set; } + public List Attachments { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Slack/Slack.cs b/src/NzbDrone.Core/Notifications/Slack/Slack.cs index 9b28b69d0..3e1459087 100644 --- a/src/NzbDrone.Core/Notifications/Slack/Slack.cs +++ b/src/NzbDrone.Core/Notifications/Slack/Slack.cs @@ -109,6 +109,7 @@ namespace NzbDrone.Core.Notifications.Slack private SlackPayload CreatePayload(string message, List attachments = null) { var icon = Settings.Icon; + var channel = Settings.Channel; var payload = new SlackPayload { @@ -130,6 +131,11 @@ namespace NzbDrone.Core.Notifications.Slack } } + if (channel.IsNotNullOrWhiteSpace()) + { + payload.Channel = channel; + } + return payload; } } diff --git a/src/NzbDrone.Core/Notifications/Slack/SlackSettings.cs b/src/NzbDrone.Core/Notifications/Slack/SlackSettings.cs index bef9b5d69..c69df6949 100644 --- a/src/NzbDrone.Core/Notifications/Slack/SlackSettings.cs +++ b/src/NzbDrone.Core/Notifications/Slack/SlackSettings.cs @@ -27,6 +27,9 @@ namespace NzbDrone.Core.Notifications.Slack [FieldDefinition(2, Label = "Icon", HelpText = "Change the icon that is used for messages from this integration (Emoji or URL)", Type = FieldType.Textbox, HelpLink = "http://www.emoji-cheat-sheet.com/")] public string Icon { get; set; } + [FieldDefinition(3, Label = "Channel", HelpText = "Overrides the default channel for the incoming webhook (#other-channel)", Type = FieldType.Textbox)] + public string Channel { get; set; } + public NzbDroneValidationResult Validate() { return new NzbDroneValidationResult(Validator.Validate(this));