From 2cbba6d7543629fdc9e1d655d9193fea664bcc4e Mon Sep 17 00:00:00 2001 From: Torkil Liseth Date: Tue, 31 Jan 2017 20:24:45 +0100 Subject: [PATCH 1/4] Fixed a typo and changed wording Fixed "Enable newslette" to "Enable newsletter", and added "es" to "adresses" in "You can add multiple email address by using the ; delimiter". --- Ombi.UI/Views/Admin/NewsletterSettings.cshtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ombi.UI/Views/Admin/NewsletterSettings.cshtml b/Ombi.UI/Views/Admin/NewsletterSettings.cshtml index 8b0d462ff..898a7a761 100644 --- a/Ombi.UI/Views/Admin/NewsletterSettings.cshtml +++ b/Ombi.UI/Views/Admin/NewsletterSettings.cshtml @@ -20,7 +20,7 @@ } else { - + } @@ -30,7 +30,7 @@
- You can add multiple email address by using the ; delimiter + You can add multiple email addresses by using the ; delimiter
@@ -115,4 +115,4 @@ }); }); - \ No newline at end of file + From 8ede1cc8dcc953b3fb09a519908c48639baacd16 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Wed, 1 Feb 2017 08:09:19 +0000 Subject: [PATCH 2/4] Fixed #1035 --- Ombi.Api.Models/Emby/EmbyUserdata.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ombi.Api.Models/Emby/EmbyUserdata.cs b/Ombi.Api.Models/Emby/EmbyUserdata.cs index fe86591d0..fece18a33 100644 --- a/Ombi.Api.Models/Emby/EmbyUserdata.cs +++ b/Ombi.Api.Models/Emby/EmbyUserdata.cs @@ -31,7 +31,7 @@ namespace Ombi.Api.Models.Emby { public class EmbyUserdata { - public int PlaybackPositionTicks { get; set; } + public double PlaybackPositionTicks { get; set; } public int PlayCount { get; set; } public bool IsFavorite { get; set; } public bool Played { get; set; } From a206141f9813d01baef0f61d66f0262c7a3b989a Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Wed, 1 Feb 2017 08:27:16 +0000 Subject: [PATCH 3/4] Fixed #1036 --- .../Notification/EmbyNotificationEngine.cs | 13 +++++++-- .../Notification/PlexNotificationEngine.cs | 17 +++++++---- Ombi.UI/Modules/RequestsModule.cs | 28 ++++++++++++++++--- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/Ombi.Services/Notification/EmbyNotificationEngine.cs b/Ombi.Services/Notification/EmbyNotificationEngine.cs index ed8f587a6..0b3bc3140 100644 --- a/Ombi.Services/Notification/EmbyNotificationEngine.cs +++ b/Ombi.Services/Notification/EmbyNotificationEngine.cs @@ -130,6 +130,7 @@ namespace Ombi.Services.Notification var embySettings = await EmbySettings.GetSettingsAsync(); var embyUsers = EmbyApi.GetUsers(embySettings.FullUri, embySettings.ApiKey); var userAccount = embyUsers.FirstOrDefault(x => x.Policy.IsAdministrator); + var localUsers = UserHelper.GetUsers().ToList(); var adminUsername = userAccount.Name ?? string.Empty; @@ -179,9 +180,15 @@ namespace Ombi.Services.Notification var email = embyUsers.FirstOrDefault(x => x.Name.Equals(user, StringComparison.CurrentCultureIgnoreCase)); if (email == null) { - Log.Info("There is no email address for this Emby user, cannot send notification"); - // We do not have a emby user that requested this! - continue; + // Local User? + var local = localUsers.FirstOrDefault(x => x.UsernameOrAlias.Equals(user)); + if (local != null) + { + + Log.Info("Sending notification to: {0} at: {1}, for title: {2}", local.UsernameOrAlias, local.EmailAddress, model.Title); + await PublishUserNotification(local.UsernameOrAlias, local.EmailAddress, model.Title, model.PosterPath, type, model.Type); + continue; + } } Log.Info("Sending notification to: {0} at: {1}, for title: {2}", email.Name, embyUser.EmailAddress, model.Title); diff --git a/Ombi.Services/Notification/PlexNotificationEngine.cs b/Ombi.Services/Notification/PlexNotificationEngine.cs index 9fbd7dc59..71108bf53 100644 --- a/Ombi.Services/Notification/PlexNotificationEngine.cs +++ b/Ombi.Services/Notification/PlexNotificationEngine.cs @@ -171,8 +171,9 @@ namespace Ombi.Services.Notification try { var settings = await PlexSettings.GetSettingsAsync(); - var plexUser = PlexApi.GetUsers(settings.PlexAuthToken); + var plexUser = PlexApi.GetUsers(settings.PlexAuthToken); // TODO emby var userAccount = PlexApi.GetAccount(settings.PlexAuthToken); + var localUsers = UserHelper.GetUsers().ToList(); var adminUsername = userAccount.Username ?? string.Empty; @@ -219,11 +220,17 @@ namespace Ombi.Services.Notification } var email = plexUser.User.FirstOrDefault(x => x.Username.Equals(user, StringComparison.CurrentCultureIgnoreCase)); - if (email == null) + if (email == null) // This is not a Plex User { - Log.Info("There is no email address for this Plex user, cannot send notification"); - // We do not have a plex user that requested this! - continue; + // Local User? + var local = localUsers.FirstOrDefault(x => x.UsernameOrAlias.Equals(user)); + if (local != null) + { + + Log.Info("Sending notification to: {0} at: {1}, for title: {2}", local.UsernameOrAlias, local.EmailAddress, model.Title); + await PublishUserNotification(local.UsernameOrAlias, local.EmailAddress, model.Title, model.PosterPath, type, model.Type); + continue; + } } Log.Info("Sending notification to: {0} at: {1}, for title: {2}", email.Username, email.Email, model.Title); diff --git a/Ombi.UI/Modules/RequestsModule.cs b/Ombi.UI/Modules/RequestsModule.cs index 193d11c33..29ffe20f1 100644 --- a/Ombi.UI/Modules/RequestsModule.cs +++ b/Ombi.UI/Modules/RequestsModule.cs @@ -66,8 +66,10 @@ namespace Ombi.UI.Modules ICacheProvider cache, IAnalytics an, IPlexNotificationEngine engine, + IEmbyNotificationEngine embyEngine, ISecurityExtensions security, - ISettingsService customSettings) : base("requests", prSettings, security) + ISettingsService customSettings, + ISettingsService embyS) : base("requests", prSettings, security) { Service = service; PrSettings = prSettings; @@ -81,8 +83,10 @@ namespace Ombi.UI.Modules CpApi = cpApi; Cache = cache; Analytics = an; - NotificationEngine = engine; + PlexNotificationEngine = engine; + EmbyNotificationEngine = embyEngine; CustomizationSettings = customSettings; + EmbySettings = embyS; Get["/", true] = async (x, ct) => await LoadRequests(); Get["/movies", true] = async (x, ct) => await GetMovies(); @@ -111,11 +115,13 @@ namespace Ombi.UI.Modules private ISettingsService SickRageSettings { get; } private ISettingsService CpSettings { get; } private ISettingsService CustomizationSettings { get; } + private ISettingsService EmbySettings { get; } private ISonarrApi SonarrApi { get; } private ISickRageApi SickRageApi { get; } private ICouchPotatoApi CpApi { get; } private ICacheProvider Cache { get; } - private INotificationEngine NotificationEngine { get; } + private INotificationEngine PlexNotificationEngine { get; } + private INotificationEngine EmbyNotificationEngine { get; } private async Task LoadRequests() { @@ -438,7 +444,21 @@ namespace Ombi.UI.Modules originalRequest.Available = available; var result = await Service.UpdateRequestAsync(originalRequest); - await NotificationEngine.NotifyUsers(originalRequest, available ? NotificationType.RequestAvailable : NotificationType.RequestDeclined); + + var plexSettings = await PlexSettings.GetSettingsAsync(); + if (plexSettings.Enable) + { + await + PlexNotificationEngine.NotifyUsers(originalRequest, + available ? NotificationType.RequestAvailable : NotificationType.RequestDeclined); + } + + var embySettings = await EmbySettings.GetSettingsAsync(); + if (embySettings.Enable) + { + await EmbyNotificationEngine.NotifyUsers(originalRequest, + available ? NotificationType.RequestAvailable : NotificationType.RequestDeclined); + } return Response.AsJson(result ? new { Result = true, Available = available, Message = string.Empty } : new { Result = false, Available = false, Message = "Could not update the availability, please try again or check the logs" }); From 4c79871bd7d6b1367b7289a63dee4bd1f3beae83 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Wed, 1 Feb 2017 08:31:13 +0000 Subject: [PATCH 4/4] Check if Emby/Plex is enabled before starting the job --- Ombi.Services/Jobs/EmbyAvailabilityChecker.cs | 5 ++++- Ombi.Services/Jobs/EmbyContentCacher.cs | 5 ++++- Ombi.Services/Jobs/PlexAvailabilityChecker.cs | 5 +++++ Ombi.Services/Jobs/PlexContentCacher.cs | 5 ++++- Ombi.Services/Notification/PlexNotificationEngine.cs | 1 + 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Ombi.Services/Jobs/EmbyAvailabilityChecker.cs b/Ombi.Services/Jobs/EmbyAvailabilityChecker.cs index 1223e3eb8..a86a7469d 100644 --- a/Ombi.Services/Jobs/EmbyAvailabilityChecker.cs +++ b/Ombi.Services/Jobs/EmbyAvailabilityChecker.cs @@ -81,7 +81,10 @@ namespace Ombi.Services.Jobs public void CheckAndUpdateAll() { var embySettings = Emby.GetSettings(); - + if (!embySettings.Enable) + { + return; + } if (!ValidateSettings(embySettings)) { Log.Debug("Validation of the Emby settings failed."); diff --git a/Ombi.Services/Jobs/EmbyContentCacher.cs b/Ombi.Services/Jobs/EmbyContentCacher.cs index ac1ba7bd2..65a47df32 100644 --- a/Ombi.Services/Jobs/EmbyContentCacher.cs +++ b/Ombi.Services/Jobs/EmbyContentCacher.cs @@ -69,7 +69,10 @@ namespace Ombi.Services.Jobs public void CacheContent() { var embySettings = Emby.GetSettings(); - + if (!embySettings.Enable) + { + return; + } if (!ValidateSettings(embySettings)) { Log.Debug("Validation of emby settings failed."); diff --git a/Ombi.Services/Jobs/PlexAvailabilityChecker.cs b/Ombi.Services/Jobs/PlexAvailabilityChecker.cs index 241da9842..e9da44eb5 100644 --- a/Ombi.Services/Jobs/PlexAvailabilityChecker.cs +++ b/Ombi.Services/Jobs/PlexAvailabilityChecker.cs @@ -82,6 +82,11 @@ namespace Ombi.Services.Jobs var plexSettings = Plex.GetSettings(); + if (!plexSettings.Enable) + { + return; + } + if (!ValidateSettings(plexSettings)) { Log.Debug("Validation of the plex settings failed."); diff --git a/Ombi.Services/Jobs/PlexContentCacher.cs b/Ombi.Services/Jobs/PlexContentCacher.cs index 9a2d770e5..936a7a60b 100644 --- a/Ombi.Services/Jobs/PlexContentCacher.cs +++ b/Ombi.Services/Jobs/PlexContentCacher.cs @@ -77,7 +77,10 @@ namespace Ombi.Services.Jobs public void CacheContent() { var plexSettings = Plex.GetSettings(); - + if (!plexSettings.Enable) + { + return; + } if (!ValidateSettings(plexSettings)) { Log.Debug("Validation of the plex settings failed."); diff --git a/Ombi.Services/Notification/PlexNotificationEngine.cs b/Ombi.Services/Notification/PlexNotificationEngine.cs index 71108bf53..3d4fcd0c8 100644 --- a/Ombi.Services/Notification/PlexNotificationEngine.cs +++ b/Ombi.Services/Notification/PlexNotificationEngine.cs @@ -171,6 +171,7 @@ namespace Ombi.Services.Notification try { var settings = await PlexSettings.GetSettingsAsync(); + var plexUser = PlexApi.GetUsers(settings.PlexAuthToken); // TODO emby var userAccount = PlexApi.GetAccount(settings.PlexAuthToken); var localUsers = UserHelper.GetUsers().ToList();