mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-15 01:32:55 -07:00
parent
8cbf2ab707
commit
b2d5996d52
17 changed files with 184 additions and 33 deletions
|
@ -54,7 +54,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task NewRequest(NotificationOptions model, DiscordNotificationSettings settings)
|
protected override async Task NewRequest(NotificationOptions model, DiscordNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.NewRequest, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -67,7 +71,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task Issue(NotificationOptions model, DiscordNotificationSettings settings)
|
protected override async Task Issue(NotificationOptions model, DiscordNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.Issue, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -105,7 +113,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestDeclined(NotificationOptions model, DiscordNotificationSettings settings)
|
protected override async Task RequestDeclined(NotificationOptions model, DiscordNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.RequestDeclined, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -117,7 +129,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestApproved(NotificationOptions model, DiscordNotificationSettings settings)
|
protected override async Task RequestApproved(NotificationOptions model, DiscordNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.RequestApproved, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -130,7 +146,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task AvailableRequest(NotificationOptions model, DiscordNotificationSettings settings)
|
protected override async Task AvailableRequest(NotificationOptions model, DiscordNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Discord, NotificationType.RequestAvailable, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MailKit.Net.Smtp;
|
using MailKit.Net.Smtp;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
|
@ -17,11 +18,14 @@ namespace Ombi.Notifications.Agents
|
||||||
{
|
{
|
||||||
public class EmailNotification : BaseNotification<EmailNotificationSettings>, IEmailNotification
|
public class EmailNotification : BaseNotification<EmailNotificationSettings>, IEmailNotification
|
||||||
{
|
{
|
||||||
public EmailNotification(ISettingsService<EmailNotificationSettings> settings, INotificationTemplatesRepository r, IMovieRequestRepository m, ITvRequestRepository t, IEmailProvider prov, ISettingsService<CustomizationSettings> c) : base(settings, r, m, t, c)
|
public EmailNotification(ISettingsService<EmailNotificationSettings> settings, INotificationTemplatesRepository r, IMovieRequestRepository m, ITvRequestRepository t, IEmailProvider prov, ISettingsService<CustomizationSettings> c,
|
||||||
|
ILogger<EmailNotification> log) : base(settings, r, m, t, c)
|
||||||
{
|
{
|
||||||
EmailProvider = prov;
|
EmailProvider = prov;
|
||||||
|
Logger = log;
|
||||||
}
|
}
|
||||||
private IEmailProvider EmailProvider { get; }
|
private IEmailProvider EmailProvider { get; }
|
||||||
|
private ILogger<EmailNotification> Logger { get; }
|
||||||
public override string NotificationName => nameof(EmailNotification);
|
public override string NotificationName => nameof(EmailNotification);
|
||||||
|
|
||||||
protected override bool ValidateConfiguration(EmailNotificationSettings settings)
|
protected override bool ValidateConfiguration(EmailNotificationSettings settings)
|
||||||
|
@ -48,7 +52,11 @@ namespace Ombi.Notifications.Agents
|
||||||
private async Task<NotificationMessage> LoadTemplate(NotificationType type, NotificationOptions model, EmailNotificationSettings settings)
|
private async Task<NotificationMessage> LoadTemplate(NotificationType type, NotificationOptions model, EmailNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Email, type, model);
|
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 email = new EmailBasicTemplate();
|
||||||
var html = email.LoadTemplate(parsed.Subject, parsed.Message,parsed.Image, Customization.Logo);
|
var html = email.LoadTemplate(parsed.Subject, parsed.Message,parsed.Image, Customization.Logo);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task NewRequest(NotificationOptions model, MattermostNotificationSettings settings)
|
protected override async Task NewRequest(NotificationOptions model, MattermostNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.NewRequest, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -62,7 +66,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task Issue(NotificationOptions model, MattermostNotificationSettings settings)
|
protected override async Task Issue(NotificationOptions model, MattermostNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.Issue, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -100,7 +108,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestDeclined(NotificationOptions model, MattermostNotificationSettings settings)
|
protected override async Task RequestDeclined(NotificationOptions model, MattermostNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.RequestDeclined, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -112,7 +124,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestApproved(NotificationOptions model, MattermostNotificationSettings settings)
|
protected override async Task RequestApproved(NotificationOptions model, MattermostNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.RequestApproved, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -125,7 +141,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task AvailableRequest(NotificationOptions model, MattermostNotificationSettings settings)
|
protected override async Task AvailableRequest(NotificationOptions model, MattermostNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Mattermost, NotificationType.RequestAvailable, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
|
|
@ -45,7 +45,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task NewRequest(NotificationOptions model, PushbulletSettings settings)
|
protected override async Task NewRequest(NotificationOptions model, PushbulletSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.NewRequest, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -57,7 +61,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task Issue(NotificationOptions model, PushbulletSettings settings)
|
protected override async Task Issue(NotificationOptions model, PushbulletSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.Issue, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -90,7 +98,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestDeclined(NotificationOptions model, PushbulletSettings settings)
|
protected override async Task RequestDeclined(NotificationOptions model, PushbulletSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.RequestDeclined, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -101,7 +113,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestApproved(NotificationOptions model, PushbulletSettings settings)
|
protected override async Task RequestApproved(NotificationOptions model, PushbulletSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.RequestApproved, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -113,7 +129,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task AvailableRequest(NotificationOptions model, PushbulletSettings settings)
|
protected override async Task AvailableRequest(NotificationOptions model, PushbulletSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushbullet, NotificationType.RequestAvailable, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
|
|
@ -46,7 +46,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task NewRequest(NotificationOptions model, PushoverSettings settings)
|
protected override async Task NewRequest(NotificationOptions model, PushoverSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.NewRequest, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -58,7 +62,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task Issue(NotificationOptions model, PushoverSettings settings)
|
protected override async Task Issue(NotificationOptions model, PushoverSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.Issue, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -91,7 +99,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestDeclined(NotificationOptions model, PushoverSettings settings)
|
protected override async Task RequestDeclined(NotificationOptions model, PushoverSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.RequestDeclined, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -102,7 +114,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestApproved(NotificationOptions model, PushoverSettings settings)
|
protected override async Task RequestApproved(NotificationOptions model, PushoverSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.RequestApproved, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -114,6 +130,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task AvailableRequest(NotificationOptions model, PushoverSettings settings)
|
protected override async Task AvailableRequest(NotificationOptions model, PushoverSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Pushover, NotificationType.RequestAvailable, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task NewRequest(NotificationOptions model, SlackNotificationSettings settings)
|
protected override async Task NewRequest(NotificationOptions model, SlackNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.NewRequest, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -68,7 +72,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task Issue(NotificationOptions model, SlackNotificationSettings settings)
|
protected override async Task Issue(NotificationOptions model, SlackNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.Issue, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -102,7 +110,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestDeclined(NotificationOptions model, SlackNotificationSettings settings)
|
protected override async Task RequestDeclined(NotificationOptions model, SlackNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.RequestDeclined, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -114,7 +126,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestApproved(NotificationOptions model, SlackNotificationSettings settings)
|
protected override async Task RequestApproved(NotificationOptions model, SlackNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.RequestApproved, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -127,7 +143,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task AvailableRequest(NotificationOptions model, SlackNotificationSettings settings)
|
protected override async Task AvailableRequest(NotificationOptions model, SlackNotificationSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Slack, NotificationType.RequestAvailable, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
|
|
@ -39,7 +39,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task NewRequest(NotificationOptions model, TelegramSettings settings)
|
protected override async Task NewRequest(NotificationOptions model, TelegramSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.NewRequest, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -51,7 +55,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task Issue(NotificationOptions model, TelegramSettings settings)
|
protected override async Task Issue(NotificationOptions model, TelegramSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.Issue, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -87,7 +95,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestDeclined(NotificationOptions model, TelegramSettings settings)
|
protected override async Task RequestDeclined(NotificationOptions model, TelegramSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.RequestDeclined, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -98,7 +110,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task RequestApproved(NotificationOptions model, TelegramSettings settings)
|
protected override async Task RequestApproved(NotificationOptions model, TelegramSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.RequestApproved, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message ?? string.Empty,
|
Message = parsed.Message ?? string.Empty,
|
||||||
|
@ -110,7 +126,11 @@ namespace Ombi.Notifications.Agents
|
||||||
protected override async Task AvailableRequest(NotificationOptions model, TelegramSettings settings)
|
protected override async Task AvailableRequest(NotificationOptions model, TelegramSettings settings)
|
||||||
{
|
{
|
||||||
var parsed = await LoadTemplate(NotificationAgent.Telegram, NotificationType.RequestAvailable, model);
|
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
|
var notification = new NotificationMessage
|
||||||
{
|
{
|
||||||
Message = parsed.Message,
|
Message = parsed.Message,
|
||||||
|
@ -122,7 +142,6 @@ namespace Ombi.Notifications.Agents
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
await Api.Send(model.Message, settings.BotApi, settings.ChatId, settings.ParseMode);
|
await Api.Send(model.Message, settings.BotApi, settings.ChatId, settings.ParseMode);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ombi.Notifications.Exceptions
|
||||||
|
{
|
||||||
|
public class TemplateMissingException : Exception
|
||||||
|
{
|
||||||
|
public TemplateMissingException() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateMissingException(string msg) : base(msg)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
|
using Ombi.Notifications.Exceptions;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
using Ombi.Settings.Settings.Models;
|
using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
|
@ -134,9 +135,13 @@ namespace Ombi.Notifications.Interfaces
|
||||||
protected virtual async Task<NotificationMessageContent> LoadTemplate(NotificationAgent agent, NotificationType type, NotificationOptions model)
|
protected virtual async Task<NotificationMessageContent> LoadTemplate(NotificationAgent agent, NotificationType type, NotificationOptions model)
|
||||||
{
|
{
|
||||||
var template = await TemplateRepository.GetTemplate(agent, type);
|
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)
|
if (!template.Enabled)
|
||||||
{
|
{
|
||||||
return null;
|
return new NotificationMessageContent {Disabled = true};
|
||||||
}
|
}
|
||||||
var parsed = Parse(model, template);
|
var parsed = Parse(model, template);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
{
|
{
|
||||||
public class NotificationMessageContent
|
public class NotificationMessageContent
|
||||||
{
|
{
|
||||||
|
public bool Disabled { get; set; }
|
||||||
public string Subject { get; set; }
|
public string Subject { get; set; }
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
public string Image { get; set; }
|
public string Image { get; set; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue