mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 04:49:33 -07:00
Fixed the emby notifications not being sent
This commit is contained in:
parent
40e732de27
commit
a957b37995
3 changed files with 15 additions and 6 deletions
|
@ -52,7 +52,6 @@ namespace Ombi.Notifications
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task Publish(NotificationOptions model)
|
public async Task Publish(NotificationOptions model)
|
||||||
{
|
{
|
||||||
//var notificationTasks = NotificationAgents.Select(notification => NotifyAsync(notification, model));
|
|
||||||
var notificationTasks = new List<Task>();
|
var notificationTasks = new List<Task>();
|
||||||
|
|
||||||
foreach (var agent in NotificationAgents)
|
foreach (var agent in NotificationAgents)
|
||||||
|
|
|
@ -30,6 +30,7 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Ombi.Core.Notifications;
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
|
@ -42,18 +43,20 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker
|
public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker
|
||||||
{
|
{
|
||||||
public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m,
|
public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m,
|
||||||
INotificationService n)
|
INotificationService n, ILogger<EmbyAvaliabilityChecker> log)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_tvRepo = t;
|
_tvRepo = t;
|
||||||
_movieRepo = m;
|
_movieRepo = m;
|
||||||
_notificationService = n;
|
_notificationService = n;
|
||||||
|
_log = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ITvRequestRepository _tvRepo;
|
private readonly ITvRequestRepository _tvRepo;
|
||||||
private readonly IMovieRequestRepository _movieRepo;
|
private readonly IMovieRequestRepository _movieRepo;
|
||||||
private readonly IEmbyContentRepository _repo;
|
private readonly IEmbyContentRepository _repo;
|
||||||
private readonly INotificationService _notificationService;
|
private readonly INotificationService _notificationService;
|
||||||
|
private readonly ILogger<EmbyAvaliabilityChecker> _log;
|
||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
|
@ -63,7 +66,7 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
|
|
||||||
private async Task ProcessMovies()
|
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)
|
foreach (var movie in movies)
|
||||||
{
|
{
|
||||||
|
@ -74,16 +77,22 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_log.LogInformation("We have found the request {0} on Emby, sending the notification", movie.Title);
|
||||||
|
|
||||||
movie.Available = true;
|
movie.Available = true;
|
||||||
if (movie.Available)
|
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
|
BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions
|
||||||
{
|
{
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.RequestAvailable,
|
NotificationType = NotificationType.RequestAvailable,
|
||||||
RequestId = movie.Id,
|
RequestId = movie.Id,
|
||||||
RequestType = RequestType.Movie,
|
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);
|
var plexEpisodes = _repo.GetAllEpisodes().Include(x => x.Series);
|
||||||
|
|
||||||
foreach (var child in tv)
|
foreach (var child in tv)
|
||||||
{
var useImdb = false;
|
{
|
||||||
|
var useImdb = false;
|
||||||
var useTvDb = false;
|
var useTvDb = false;
|
||||||
if (child.ParentRequest.ImdbId.HasValue())
|
if (child.ParentRequest.ImdbId.HasValue())
|
||||||
{
|
{
|
||||||
|
@ -104,7 +105,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
||||||
private async Task ProcessMovies()
|
private async Task ProcessMovies()
|
||||||
{
|
{
|
||||||
// Get all non available
|
// 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)
|
foreach (var movie in movies)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue