Fixed the emby notifications not being sent

pull/1805/head
Jamie 7 years ago
parent 40e732de27
commit a957b37995

@ -52,7 +52,6 @@ namespace Ombi.Notifications
/// <returns></returns>
public async Task Publish(NotificationOptions model)
{
//var notificationTasks = NotificationAgents.Select(notification => NotifyAsync(notification, model));
var notificationTasks = new List<Task>();
foreach (var agent in NotificationAgents)

@ -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<EmbyAvaliabilityChecker> 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<EmbyAvaliabilityChecker> _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,
}));
}
}

@ -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)
{

Loading…
Cancel
Save