mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
#1588 When we make changes to any requests that we can trigger a notification, always send it to all notification agents, even if the user wont recieve it.
This commit is contained in:
parent
2ec87ac3d6
commit
9261232bab
9 changed files with 101 additions and 29 deletions
|
@ -9,12 +9,11 @@ namespace Ombi.Core.Engine.Interfaces
|
|||
{
|
||||
|
||||
Task RemoveTvRequest(int requestId);
|
||||
|
||||
Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv);
|
||||
|
||||
Task<ChildRequests> DenyChildRequest(ChildRequests request);
|
||||
Task<ChildRequests> ChangeAvailability(ChildRequests request);
|
||||
Task<IEnumerable<TvRequests>> SearchTvRequest(string search);
|
||||
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search);
|
||||
|
||||
Task<TvRequests> UpdateTvRequest(TvRequests request);
|
||||
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> GetRequestsTreeNode(int count, int position);
|
||||
Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId);
|
||||
|
|
|
@ -86,12 +86,12 @@ namespace Ombi.Core.Engine
|
|||
|
||||
if (requestModel.Approved) // The rules have auto approved this
|
||||
{
|
||||
var result = await Sender.Send(requestModel);
|
||||
if (result.Success && result.Sent)
|
||||
var result = await ApproveMovie(requestModel);
|
||||
if (result.RequestAdded)
|
||||
{
|
||||
return await AddMovieRequest(requestModel, fullMovieName);
|
||||
}
|
||||
if (!result.Success)
|
||||
if (!result.IsError)
|
||||
{
|
||||
Logger.LogWarning("Tried auto sending movie but failed. Message: {0}", result.Message);
|
||||
return new RequestEngineResult
|
||||
|
@ -150,6 +150,7 @@ namespace Ombi.Core.Engine
|
|||
public async Task<RequestEngineResult> ApproveMovie(MovieRequests request)
|
||||
{
|
||||
await MovieRepository.Update(request);
|
||||
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
||||
if (request.Approved)
|
||||
{
|
||||
var result = await Sender.Send(request);
|
||||
|
@ -189,6 +190,17 @@ namespace Ombi.Core.Engine
|
|||
var allRequests = await MovieRepository.Get().ToListAsync();
|
||||
var results = allRequests.FirstOrDefault(x => x.Id == request.Id);
|
||||
|
||||
if (!(results.Denied ?? false) && (request.Denied ?? false))
|
||||
{
|
||||
// We are denying a request
|
||||
NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
||||
}
|
||||
if (!results.Available && request.Available)
|
||||
{
|
||||
// We changed the availability manually
|
||||
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
||||
}
|
||||
|
||||
results.Approved = request.Approved;
|
||||
results.Available = request.Available;
|
||||
results.Denied = request.Denied;
|
||||
|
|
|
@ -183,6 +183,7 @@ namespace Ombi.Core.Engine
|
|||
await TvRepository.UpdateChild(request);
|
||||
if (request.Approved)
|
||||
{
|
||||
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
||||
await Audit.Record(AuditType.Approved, AuditArea.TvRequest, $"Approved Request {request.Title}", Username);
|
||||
// Autosend
|
||||
await TvSender.Send(request);
|
||||
|
@ -193,6 +194,21 @@ namespace Ombi.Core.Engine
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<ChildRequests> DenyChildRequest(ChildRequests request)
|
||||
{
|
||||
NotificationHelper.Notify(request, NotificationType.RequestDeclined);
|
||||
return await UpdateChildRequest(request);
|
||||
}
|
||||
|
||||
public async Task<ChildRequests> ChangeAvailability(ChildRequests request)
|
||||
{
|
||||
if (request.Available)
|
||||
{
|
||||
NotificationHelper.Notify(request, NotificationType.RequestAvailable);
|
||||
}
|
||||
return await UpdateChildRequest(request);
|
||||
}
|
||||
|
||||
public async Task<ChildRequests> UpdateChildRequest(ChildRequests request)
|
||||
{
|
||||
await Audit.Record(AuditType.Updated, AuditArea.TvRequest, $"Updated Request {request.Title}", Username);
|
||||
|
@ -289,6 +305,7 @@ namespace Ombi.Core.Engine
|
|||
if (model.Approved)
|
||||
{
|
||||
// Autosend
|
||||
NotificationHelper.Notify(model, NotificationType.RequestApproved);
|
||||
var result = await TvSender.Send(model);
|
||||
if (result.Success)
|
||||
{
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using Hangfire;
|
||||
using Ombi.Core.Models.Requests;
|
||||
using Ombi.Core.Notifications;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Notifications.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
|
||||
namespace Ombi.Core
|
||||
|
@ -29,6 +27,7 @@ namespace Ombi.Core
|
|||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
||||
|
||||
}
|
||||
|
||||
public void NewRequest(ChildRequests model)
|
||||
{
|
||||
var notificationModel = new NotificationOptions
|
||||
|
@ -39,7 +38,32 @@ namespace Ombi.Core
|
|||
RequestType = model.RequestType
|
||||
};
|
||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
||||
}
|
||||
|
||||
|
||||
public void Notify(MovieRequests model, NotificationType type)
|
||||
{
|
||||
var notificationModel = new NotificationOptions
|
||||
{
|
||||
RequestId = model.Id,
|
||||
DateTime = DateTime.Now,
|
||||
NotificationType = type,
|
||||
RequestType = model.RequestType,
|
||||
Recipient = model.RequestedUser.Email
|
||||
};
|
||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
||||
}
|
||||
public void Notify(ChildRequests model, NotificationType type)
|
||||
{
|
||||
var notificationModel = new NotificationOptions
|
||||
{
|
||||
RequestId = model.Id,
|
||||
DateTime = DateTime.Now,
|
||||
NotificationType = type,
|
||||
RequestType = model.RequestType,
|
||||
Recipient = model.RequestedUser.Email
|
||||
};
|
||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using Ombi.Core.Models.Requests;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
|
||||
namespace Ombi.Core
|
||||
|
@ -7,5 +8,7 @@ namespace Ombi.Core
|
|||
{
|
||||
void NewRequest(FullBaseRequest model);
|
||||
void NewRequest(ChildRequests model);
|
||||
void Notify(MovieRequests model, NotificationType type);
|
||||
void Notify(ChildRequests model, NotificationType type);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue