From b2d5996d52acd7d03b887baf1885ac4c70dd812a Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 29 Nov 2017 08:21:39 +0000 Subject: [PATCH] #1732 #1722 #1711 --- .../Agents/DiscordNotification.cs | 30 +++++++++++++++--- .../Agents/EmailNotification.cs | 12 +++++-- .../{ => Interfaces}/IDiscordNotification.cs | 0 .../{ => Interfaces}/IEmailNotification.cs | 0 .../IMattermostNotification.cs | 0 .../IPushbulletNotification.cs | 0 .../{ => Interfaces}/IPushoverNotification.cs | 0 .../{ => Interfaces}/ISlackNotification.cs | 0 .../{ => Interfaces}/ITelegramNotification.cs | 0 .../Agents/MattermostNotification.cs | 30 +++++++++++++++--- .../Agents/PushbulletNotification.cs | 30 +++++++++++++++--- .../Agents/PushoverNotification.cs | 29 ++++++++++++++--- .../Agents/SlackNotification.cs | 30 +++++++++++++++--- .../Agents/TelegramNotification.cs | 31 +++++++++++++++---- .../Exceptions/TemplateMissingException.cs | 17 ++++++++++ .../Interfaces/BaseNotification.cs | 7 ++++- .../NotificationMessageContent.cs | 1 + 17 files changed, 184 insertions(+), 33 deletions(-) rename src/Ombi.Notifications/Agents/{ => Interfaces}/IDiscordNotification.cs (100%) rename src/Ombi.Notifications/Agents/{ => Interfaces}/IEmailNotification.cs (100%) rename src/Ombi.Notifications/Agents/{ => Interfaces}/IMattermostNotification.cs (100%) rename src/Ombi.Notifications/Agents/{ => Interfaces}/IPushbulletNotification.cs (100%) rename src/Ombi.Notifications/Agents/{ => Interfaces}/IPushoverNotification.cs (100%) rename src/Ombi.Notifications/Agents/{ => Interfaces}/ISlackNotification.cs (100%) rename src/Ombi.Notifications/Agents/{ => Interfaces}/ITelegramNotification.cs (100%) create mode 100644 src/Ombi.Notifications/Exceptions/TemplateMissingException.cs diff --git a/src/Ombi.Notifications/Agents/DiscordNotification.cs b/src/Ombi.Notifications/Agents/DiscordNotification.cs index 92cd8bdf2..5e9eab8c2 100644 --- a/src/Ombi.Notifications/Agents/DiscordNotification.cs +++ b/src/Ombi.Notifications/Agents/DiscordNotification.cs @@ -54,7 +54,11 @@ namespace Ombi.Notifications.Agents protected override async Task NewRequest(NotificationOptions model, DiscordNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.NewRequest, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.NewRequest} is disabled for {NotificationAgent.Discord}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -67,7 +71,11 @@ namespace Ombi.Notifications.Agents protected override async Task Issue(NotificationOptions model, DiscordNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.Issue, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.Issue} is disabled for {NotificationAgent.Discord}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -105,7 +113,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestDeclined(NotificationOptions model, DiscordNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.RequestDeclined, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestDeclined} is disabled for {NotificationAgent.Discord}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -117,7 +129,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestApproved(NotificationOptions model, DiscordNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.RequestApproved, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestApproved} is disabled for {NotificationAgent.Discord}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -130,7 +146,11 @@ namespace Ombi.Notifications.Agents protected override async Task AvailableRequest(NotificationOptions model, DiscordNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.RequestAvailable, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestAvailable} is disabled for {NotificationAgent.Discord}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, diff --git a/src/Ombi.Notifications/Agents/EmailNotification.cs b/src/Ombi.Notifications/Agents/EmailNotification.cs index 8265d995b..8c42a82d6 100644 --- a/src/Ombi.Notifications/Agents/EmailNotification.cs +++ b/src/Ombi.Notifications/Agents/EmailNotification.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using MailKit.Net.Smtp; +using Microsoft.Extensions.Logging; using MimeKit; using Ombi.Core.Settings; using Ombi.Helpers; @@ -17,11 +18,14 @@ namespace Ombi.Notifications.Agents { public class EmailNotification : BaseNotification, IEmailNotification { - public EmailNotification(ISettingsService settings, INotificationTemplatesRepository r, IMovieRequestRepository m, ITvRequestRepository t, IEmailProvider prov, ISettingsService c) : base(settings, r, m, t, c) + public EmailNotification(ISettingsService settings, INotificationTemplatesRepository r, IMovieRequestRepository m, ITvRequestRepository t, IEmailProvider prov, ISettingsService c, + ILogger log) : base(settings, r, m, t, c) { EmailProvider = prov; + Logger = log; } private IEmailProvider EmailProvider { get; } + private ILogger Logger { get; } public override string NotificationName => nameof(EmailNotification); protected override bool ValidateConfiguration(EmailNotificationSettings settings) @@ -48,7 +52,11 @@ namespace Ombi.Notifications.Agents private async Task LoadTemplate(NotificationType type, NotificationOptions model, EmailNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Email, type, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {type} is disabled for {NotificationAgent.Email}"); + return null; + } var email = new EmailBasicTemplate(); var html = email.LoadTemplate(parsed.Subject, parsed.Message,parsed.Image, Customization.Logo); diff --git a/src/Ombi.Notifications/Agents/IDiscordNotification.cs b/src/Ombi.Notifications/Agents/Interfaces/IDiscordNotification.cs similarity index 100% rename from src/Ombi.Notifications/Agents/IDiscordNotification.cs rename to src/Ombi.Notifications/Agents/Interfaces/IDiscordNotification.cs diff --git a/src/Ombi.Notifications/Agents/IEmailNotification.cs b/src/Ombi.Notifications/Agents/Interfaces/IEmailNotification.cs similarity index 100% rename from src/Ombi.Notifications/Agents/IEmailNotification.cs rename to src/Ombi.Notifications/Agents/Interfaces/IEmailNotification.cs diff --git a/src/Ombi.Notifications/Agents/IMattermostNotification.cs b/src/Ombi.Notifications/Agents/Interfaces/IMattermostNotification.cs similarity index 100% rename from src/Ombi.Notifications/Agents/IMattermostNotification.cs rename to src/Ombi.Notifications/Agents/Interfaces/IMattermostNotification.cs diff --git a/src/Ombi.Notifications/Agents/IPushbulletNotification.cs b/src/Ombi.Notifications/Agents/Interfaces/IPushbulletNotification.cs similarity index 100% rename from src/Ombi.Notifications/Agents/IPushbulletNotification.cs rename to src/Ombi.Notifications/Agents/Interfaces/IPushbulletNotification.cs diff --git a/src/Ombi.Notifications/Agents/IPushoverNotification.cs b/src/Ombi.Notifications/Agents/Interfaces/IPushoverNotification.cs similarity index 100% rename from src/Ombi.Notifications/Agents/IPushoverNotification.cs rename to src/Ombi.Notifications/Agents/Interfaces/IPushoverNotification.cs diff --git a/src/Ombi.Notifications/Agents/ISlackNotification.cs b/src/Ombi.Notifications/Agents/Interfaces/ISlackNotification.cs similarity index 100% rename from src/Ombi.Notifications/Agents/ISlackNotification.cs rename to src/Ombi.Notifications/Agents/Interfaces/ISlackNotification.cs diff --git a/src/Ombi.Notifications/Agents/ITelegramNotification.cs b/src/Ombi.Notifications/Agents/Interfaces/ITelegramNotification.cs similarity index 100% rename from src/Ombi.Notifications/Agents/ITelegramNotification.cs rename to src/Ombi.Notifications/Agents/Interfaces/ITelegramNotification.cs diff --git a/src/Ombi.Notifications/Agents/MattermostNotification.cs b/src/Ombi.Notifications/Agents/MattermostNotification.cs index 8d627c5b8..d3cc9e9c9 100644 --- a/src/Ombi.Notifications/Agents/MattermostNotification.cs +++ b/src/Ombi.Notifications/Agents/MattermostNotification.cs @@ -49,7 +49,11 @@ namespace Ombi.Notifications.Agents protected override async Task NewRequest(NotificationOptions model, MattermostNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.NewRequest, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.NewRequest} is disabled for {NotificationAgent.Mattermost}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -62,7 +66,11 @@ namespace Ombi.Notifications.Agents protected override async Task Issue(NotificationOptions model, MattermostNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.Issue, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.Issue} is disabled for {NotificationAgent.Mattermost}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -100,7 +108,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestDeclined(NotificationOptions model, MattermostNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.RequestDeclined, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestDeclined} is disabled for {NotificationAgent.Mattermost}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -112,7 +124,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestApproved(NotificationOptions model, MattermostNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.RequestApproved, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestApproved} is disabled for {NotificationAgent.Mattermost}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -125,7 +141,11 @@ namespace Ombi.Notifications.Agents protected override async Task AvailableRequest(NotificationOptions model, MattermostNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.RequestAvailable, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestAvailable} is disabled for {NotificationAgent.Mattermost}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, diff --git a/src/Ombi.Notifications/Agents/PushbulletNotification.cs b/src/Ombi.Notifications/Agents/PushbulletNotification.cs index d16a6e6b5..28df9f589 100644 --- a/src/Ombi.Notifications/Agents/PushbulletNotification.cs +++ b/src/Ombi.Notifications/Agents/PushbulletNotification.cs @@ -45,7 +45,11 @@ namespace Ombi.Notifications.Agents protected override async Task NewRequest(NotificationOptions model, PushbulletSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.NewRequest, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.NewRequest} is disabled for {NotificationAgent.Pushbullet}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -57,7 +61,11 @@ namespace Ombi.Notifications.Agents protected override async Task Issue(NotificationOptions model, PushbulletSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.Issue, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.Issue} is disabled for {NotificationAgent.Pushbullet}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -90,7 +98,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestDeclined(NotificationOptions model, PushbulletSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.RequestDeclined, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestDeclined} is disabled for {NotificationAgent.Pushbullet}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -101,7 +113,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestApproved(NotificationOptions model, PushbulletSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.RequestApproved, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestApproved} is disabled for {NotificationAgent.Pushbullet}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -113,7 +129,11 @@ namespace Ombi.Notifications.Agents protected override async Task AvailableRequest(NotificationOptions model, PushbulletSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.RequestAvailable, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestAvailable} is disabled for {NotificationAgent.Pushbullet}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, diff --git a/src/Ombi.Notifications/Agents/PushoverNotification.cs b/src/Ombi.Notifications/Agents/PushoverNotification.cs index 0c5c8414b..f78cfcdbf 100644 --- a/src/Ombi.Notifications/Agents/PushoverNotification.cs +++ b/src/Ombi.Notifications/Agents/PushoverNotification.cs @@ -46,7 +46,11 @@ namespace Ombi.Notifications.Agents protected override async Task NewRequest(NotificationOptions model, PushoverSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.NewRequest, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.NewRequest} is disabled for {NotificationAgent.Pushover}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -58,7 +62,11 @@ namespace Ombi.Notifications.Agents protected override async Task Issue(NotificationOptions model, PushoverSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.Issue, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.Issue} is disabled for {NotificationAgent.Pushover}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -91,7 +99,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestDeclined(NotificationOptions model, PushoverSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.RequestDeclined, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestDeclined} is disabled for {NotificationAgent.Pushover}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -102,7 +114,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestApproved(NotificationOptions model, PushoverSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.RequestApproved, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestApproved} is disabled for {NotificationAgent.Pushover}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -114,6 +130,11 @@ namespace Ombi.Notifications.Agents protected override async Task AvailableRequest(NotificationOptions model, PushoverSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.RequestAvailable, model); + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestAvailable} is disabled for {NotificationAgent.Pushover}"); + return; + } var notification = new NotificationMessage { diff --git a/src/Ombi.Notifications/Agents/SlackNotification.cs b/src/Ombi.Notifications/Agents/SlackNotification.cs index 7ff71f84f..c5f1dece2 100644 --- a/src/Ombi.Notifications/Agents/SlackNotification.cs +++ b/src/Ombi.Notifications/Agents/SlackNotification.cs @@ -55,7 +55,11 @@ namespace Ombi.Notifications.Agents protected override async Task NewRequest(NotificationOptions model, SlackNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.NewRequest, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.NewRequest} is disabled for {NotificationAgent.Slack}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -68,7 +72,11 @@ namespace Ombi.Notifications.Agents protected override async Task Issue(NotificationOptions model, SlackNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.Issue, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.Issue} is disabled for {NotificationAgent.Slack}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -102,7 +110,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestDeclined(NotificationOptions model, SlackNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.RequestDeclined, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestDeclined} is disabled for {NotificationAgent.Slack}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -114,7 +126,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestApproved(NotificationOptions model, SlackNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.RequestApproved, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestApproved} is disabled for {NotificationAgent.Slack}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -127,7 +143,11 @@ namespace Ombi.Notifications.Agents protected override async Task AvailableRequest(NotificationOptions model, SlackNotificationSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.RequestAvailable, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestAvailable} is disabled for {NotificationAgent.Slack}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, diff --git a/src/Ombi.Notifications/Agents/TelegramNotification.cs b/src/Ombi.Notifications/Agents/TelegramNotification.cs index 5773b95d7..457b5573a 100644 --- a/src/Ombi.Notifications/Agents/TelegramNotification.cs +++ b/src/Ombi.Notifications/Agents/TelegramNotification.cs @@ -39,7 +39,11 @@ namespace Ombi.Notifications.Agents protected override async Task NewRequest(NotificationOptions model, TelegramSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.NewRequest, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.NewRequest} is disabled for {NotificationAgent.Telegram}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -51,7 +55,11 @@ namespace Ombi.Notifications.Agents protected override async Task Issue(NotificationOptions model, TelegramSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.Issue, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.Issue} is disabled for {NotificationAgent.Telegram}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -87,7 +95,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestDeclined(NotificationOptions model, TelegramSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.RequestDeclined, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestDeclined} is disabled for {NotificationAgent.Telegram}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -98,7 +110,11 @@ namespace Ombi.Notifications.Agents protected override async Task RequestApproved(NotificationOptions model, TelegramSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.RequestApproved, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestApproved} is disabled for {NotificationAgent.Telegram}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message ?? string.Empty, @@ -110,7 +126,11 @@ namespace Ombi.Notifications.Agents protected override async Task AvailableRequest(NotificationOptions model, TelegramSettings settings) { var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.RequestAvailable, model); - + if (parsed.Disabled) + { + Logger.LogInformation($"Template {NotificationType.RequestAvailable} is disabled for {NotificationAgent.Telegram}"); + return; + } var notification = new NotificationMessage { Message = parsed.Message, @@ -122,7 +142,6 @@ namespace Ombi.Notifications.Agents { try { - await Api.Send(model.Message, settings.BotApi, settings.ChatId, settings.ParseMode); } catch (Exception e) diff --git a/src/Ombi.Notifications/Exceptions/TemplateMissingException.cs b/src/Ombi.Notifications/Exceptions/TemplateMissingException.cs new file mode 100644 index 000000000..e5454302a --- /dev/null +++ b/src/Ombi.Notifications/Exceptions/TemplateMissingException.cs @@ -0,0 +1,17 @@ +using System; + +namespace Ombi.Notifications.Exceptions +{ + public class TemplateMissingException : Exception + { + public TemplateMissingException() : base() + { + + } + + public TemplateMissingException(string msg) : base(msg) + { + + } + } +} \ No newline at end of file diff --git a/src/Ombi.Notifications/Interfaces/BaseNotification.cs b/src/Ombi.Notifications/Interfaces/BaseNotification.cs index f14947105..91e4469e8 100644 --- a/src/Ombi.Notifications/Interfaces/BaseNotification.cs +++ b/src/Ombi.Notifications/Interfaces/BaseNotification.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Ombi.Core.Settings; using Ombi.Helpers; +using Ombi.Notifications.Exceptions; using Ombi.Notifications.Models; using Ombi.Settings.Settings.Models; using Ombi.Store.Entities; @@ -134,9 +135,13 @@ namespace Ombi.Notifications.Interfaces protected virtual async Task LoadTemplate(NotificationAgent agent, NotificationType type, NotificationOptions model) { var template = await TemplateRepository.GetTemplate(agent, type); + if (template == null) + { + throw new TemplateMissingException($"The template for {agent} and type {type} is missing"); + } if (!template.Enabled) { - return null; + return new NotificationMessageContent {Disabled = true}; } var parsed = Parse(model, template); diff --git a/src/Ombi.Notifications/NotificationMessageContent.cs b/src/Ombi.Notifications/NotificationMessageContent.cs index e70b88072..37f7504e9 100644 --- a/src/Ombi.Notifications/NotificationMessageContent.cs +++ b/src/Ombi.Notifications/NotificationMessageContent.cs @@ -2,6 +2,7 @@ { public class NotificationMessageContent { + public bool Disabled { get; set; } public string Subject { get; set; } public string Message { get; set; } public string Image { get; set; }