From bcfd675d3d06a6ba75bb56fd1bdd5549032fdae4 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Tue, 8 Nov 2016 14:36:01 +0000 Subject: [PATCH] Finished the notification for the fault queue --- .../Notification/PushbulletNotification.cs | 12 ++++++++++++ .../Notification/PushoverNotification.cs | 11 +++++++++++ .../Notification/SlackNotification.cs | 11 +++++++++++ 3 files changed, 34 insertions(+) diff --git a/PlexRequests.Services/Notification/PushbulletNotification.cs b/PlexRequests.Services/Notification/PushbulletNotification.cs index e2ae3c4c4..ff1d2e48d 100644 --- a/PlexRequests.Services/Notification/PushbulletNotification.cs +++ b/PlexRequests.Services/Notification/PushbulletNotification.cs @@ -81,6 +81,11 @@ namespace PlexRequests.Services.Notification case NotificationType.Test: await PushTestAsync(pushSettings); break; + case NotificationType.RequestDeclined: + break; + case NotificationType.ItemAddedToFaultQueue: + await PushFaultQueue(model, pushSettings); + break; default: throw new ArgumentOutOfRangeException(); } @@ -125,6 +130,13 @@ namespace PlexRequests.Services.Notification await Push(settings, message, pushTitle); } + private async Task PushFaultQueue(NotificationModel model, PushbulletNotificationSettings settings) + { + var message = $"Hello! The user '{model.User}' has requested {model.Title} but it could not be added. This has been added into the requests queue and will keep retrying"; + var pushTitle = $"Plex Requests: The {model.RequestType.GetString()?.ToLower()} {model.Title} has been requested but could not be added!"; + await Push(settings, message, pushTitle); + } + private async Task Push(PushbulletNotificationSettings settings, string message, string title) { try diff --git a/PlexRequests.Services/Notification/PushoverNotification.cs b/PlexRequests.Services/Notification/PushoverNotification.cs index 2adafb11e..f04ed8560 100644 --- a/PlexRequests.Services/Notification/PushoverNotification.cs +++ b/PlexRequests.Services/Notification/PushoverNotification.cs @@ -81,6 +81,11 @@ namespace PlexRequests.Services.Notification case NotificationType.Test: await PushTestAsync(model, pushSettings); break; + case NotificationType.RequestDeclined: + break; + case NotificationType.ItemAddedToFaultQueue: + await PushFaultQueue(model, pushSettings); + break; default: throw new ArgumentOutOfRangeException(); } @@ -122,6 +127,12 @@ namespace PlexRequests.Services.Notification await Push(settings, message); } + private async Task PushFaultQueue(NotificationModel model, PushoverNotificationSettings settings) + { + var message = $"Hello! The user '{model.User}' has requested {model.Title} but it could not be added. This has been added into the requests queue and will keep retrying"; + await Push(settings, message); + } + private async Task Push(PushoverNotificationSettings settings, string message) { try diff --git a/PlexRequests.Services/Notification/SlackNotification.cs b/PlexRequests.Services/Notification/SlackNotification.cs index f8c90d3ca..41ce4cc05 100644 --- a/PlexRequests.Services/Notification/SlackNotification.cs +++ b/PlexRequests.Services/Notification/SlackNotification.cs @@ -88,6 +88,11 @@ namespace PlexRequests.Services.Notification case NotificationType.Test: await PushTest(pushSettings); break; + case NotificationType.RequestDeclined: + break; + case NotificationType.ItemAddedToFaultQueue: + await PushFaultQueue(model, pushSettings); + break; default: throw new ArgumentOutOfRangeException(); } @@ -111,6 +116,12 @@ namespace PlexRequests.Services.Notification await Push(settings, message); } + private async Task PushFaultQueue(NotificationModel model, SlackNotificationSettings settings) + { + var message = $"Hello! The user '{model.User}' has requested {model.Title} but it could not be added. This has been added into the requests queue and will keep retrying"; + await Push(settings, message); + } + private async Task Push(SlackNotificationSettings config, string message) { try