From a957b37995f91531b2288feb811ceb07f8922d46 Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 20 Dec 2017 11:45:35 +0000 Subject: [PATCH] Fixed the emby notifications not being sent --- src/Ombi.Notifications/NotificationService.cs | 1 - .../Jobs/Emby/EmbyAvaliabilityChecker.cs | 15 ++++++++++++--- .../Jobs/Plex/PlexAvailabilityChecker.cs | 5 +++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Ombi.Notifications/NotificationService.cs b/src/Ombi.Notifications/NotificationService.cs index 49e1d24a0..53bb23bd6 100644 --- a/src/Ombi.Notifications/NotificationService.cs +++ b/src/Ombi.Notifications/NotificationService.cs @@ -52,7 +52,6 @@ namespace Ombi.Notifications /// public async Task Publish(NotificationOptions model) { - //var notificationTasks = NotificationAgents.Select(notification => NotifyAsync(notification, model)); var notificationTasks = new List(); foreach (var agent in NotificationAgents) diff --git a/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs b/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs index e5b47153d..4c765d83f 100644 --- a/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Emby/EmbyAvaliabilityChecker.cs @@ -30,6 +30,7 @@ using System.Linq; using System.Threading.Tasks; using Hangfire; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using Ombi.Core.Notifications; using Ombi.Helpers; using Ombi.Notifications.Models; @@ -42,18 +43,20 @@ namespace Ombi.Schedule.Jobs.Emby public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker { public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m, - INotificationService n) + INotificationService n, ILogger log) { _repo = repo; _tvRepo = t; _movieRepo = m; _notificationService = n; + _log = log; } private readonly ITvRequestRepository _tvRepo; private readonly IMovieRequestRepository _movieRepo; private readonly IEmbyContentRepository _repo; private readonly INotificationService _notificationService; + private readonly ILogger _log; public async Task Start() { @@ -63,7 +66,7 @@ namespace Ombi.Schedule.Jobs.Emby private async Task ProcessMovies() { - var movies = _movieRepo.GetAll().Where(x => !x.Available); + var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available); foreach (var movie in movies) { @@ -74,16 +77,22 @@ namespace Ombi.Schedule.Jobs.Emby continue; } + _log.LogInformation("We have found the request {0} on Emby, sending the notification", movie.Title); + movie.Available = true; if (movie.Available) { + var recipient = movie.RequestedUser.Email.HasValue() ? movie.RequestedUser.Email : string.Empty; + + _log.LogDebug("MovieId: {0}, RequestUser: {1}", movie.Id, recipient); + BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions { DateTime = DateTime.Now, NotificationType = NotificationType.RequestAvailable, RequestId = movie.Id, RequestType = RequestType.Movie, - Recipient = movie.RequestedUser.Email.HasValue() ? movie.RequestedUser.Email : string.Empty, + Recipient = recipient, })); } } diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs index 9a32bb2fe..adb9b7d30 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs @@ -43,7 +43,8 @@ namespace Ombi.Schedule.Jobs.Plex var plexEpisodes = _repo.GetAllEpisodes().Include(x => x.Series); foreach (var child in tv) - { var useImdb = false; + { + var useImdb = false; var useTvDb = false; if (child.ParentRequest.ImdbId.HasValue()) { @@ -104,7 +105,7 @@ namespace Ombi.Schedule.Jobs.Plex private async Task ProcessMovies() { // Get all non available - var movies = _movieRepo.GetAll().Where(x => !x.Available); + var movies = _movieRepo.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available); foreach (var movie in movies) {