mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-13 00:32:57 -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 RemoveTvRequest(int requestId);
|
||||||
|
|
||||||
Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv);
|
Task<RequestEngineResult> RequestTvShow(SearchTvShowViewModel tv);
|
||||||
|
Task<ChildRequests> DenyChildRequest(ChildRequests request);
|
||||||
|
Task<ChildRequests> ChangeAvailability(ChildRequests request);
|
||||||
Task<IEnumerable<TvRequests>> SearchTvRequest(string search);
|
Task<IEnumerable<TvRequests>> SearchTvRequest(string search);
|
||||||
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search);
|
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search);
|
||||||
|
|
||||||
Task<TvRequests> UpdateTvRequest(TvRequests request);
|
Task<TvRequests> UpdateTvRequest(TvRequests request);
|
||||||
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> GetRequestsTreeNode(int count, int position);
|
Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> GetRequestsTreeNode(int count, int position);
|
||||||
Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId);
|
Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId);
|
||||||
|
|
|
@ -86,12 +86,12 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
if (requestModel.Approved) // The rules have auto approved this
|
if (requestModel.Approved) // The rules have auto approved this
|
||||||
{
|
{
|
||||||
var result = await Sender.Send(requestModel);
|
var result = await ApproveMovie(requestModel);
|
||||||
if (result.Success && result.Sent)
|
if (result.RequestAdded)
|
||||||
{
|
{
|
||||||
return await AddMovieRequest(requestModel, fullMovieName);
|
return await AddMovieRequest(requestModel, fullMovieName);
|
||||||
}
|
}
|
||||||
if (!result.Success)
|
if (!result.IsError)
|
||||||
{
|
{
|
||||||
Logger.LogWarning("Tried auto sending movie but failed. Message: {0}", result.Message);
|
Logger.LogWarning("Tried auto sending movie but failed. Message: {0}", result.Message);
|
||||||
return new RequestEngineResult
|
return new RequestEngineResult
|
||||||
|
@ -150,6 +150,7 @@ namespace Ombi.Core.Engine
|
||||||
public async Task<RequestEngineResult> ApproveMovie(MovieRequests request)
|
public async Task<RequestEngineResult> ApproveMovie(MovieRequests request)
|
||||||
{
|
{
|
||||||
await MovieRepository.Update(request);
|
await MovieRepository.Update(request);
|
||||||
|
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
||||||
if (request.Approved)
|
if (request.Approved)
|
||||||
{
|
{
|
||||||
var result = await Sender.Send(request);
|
var result = await Sender.Send(request);
|
||||||
|
@ -189,6 +190,17 @@ namespace Ombi.Core.Engine
|
||||||
var allRequests = await MovieRepository.Get().ToListAsync();
|
var allRequests = await MovieRepository.Get().ToListAsync();
|
||||||
var results = allRequests.FirstOrDefault(x => x.Id == request.Id);
|
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.Approved = request.Approved;
|
||||||
results.Available = request.Available;
|
results.Available = request.Available;
|
||||||
results.Denied = request.Denied;
|
results.Denied = request.Denied;
|
||||||
|
|
|
@ -183,6 +183,7 @@ namespace Ombi.Core.Engine
|
||||||
await TvRepository.UpdateChild(request);
|
await TvRepository.UpdateChild(request);
|
||||||
if (request.Approved)
|
if (request.Approved)
|
||||||
{
|
{
|
||||||
|
NotificationHelper.Notify(request, NotificationType.RequestApproved);
|
||||||
await Audit.Record(AuditType.Approved, AuditArea.TvRequest, $"Approved Request {request.Title}", Username);
|
await Audit.Record(AuditType.Approved, AuditArea.TvRequest, $"Approved Request {request.Title}", Username);
|
||||||
// Autosend
|
// Autosend
|
||||||
await TvSender.Send(request);
|
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)
|
public async Task<ChildRequests> UpdateChildRequest(ChildRequests request)
|
||||||
{
|
{
|
||||||
await Audit.Record(AuditType.Updated, AuditArea.TvRequest, $"Updated Request {request.Title}", Username);
|
await Audit.Record(AuditType.Updated, AuditArea.TvRequest, $"Updated Request {request.Title}", Username);
|
||||||
|
@ -289,6 +305,7 @@ namespace Ombi.Core.Engine
|
||||||
if (model.Approved)
|
if (model.Approved)
|
||||||
{
|
{
|
||||||
// Autosend
|
// Autosend
|
||||||
|
NotificationHelper.Notify(model, NotificationType.RequestApproved);
|
||||||
var result = await TvSender.Send(model);
|
var result = await TvSender.Send(model);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Ombi.Core.Models.Requests;
|
|
||||||
using Ombi.Core.Notifications;
|
using Ombi.Core.Notifications;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Notifications.Models;
|
using Ombi.Notifications.Models;
|
||||||
using Ombi.Store.Entities;
|
|
||||||
using Ombi.Store.Entities.Requests;
|
using Ombi.Store.Entities.Requests;
|
||||||
|
|
||||||
namespace Ombi.Core
|
namespace Ombi.Core
|
||||||
|
@ -29,6 +27,7 @@ namespace Ombi.Core
|
||||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NewRequest(ChildRequests model)
|
public void NewRequest(ChildRequests model)
|
||||||
{
|
{
|
||||||
var notificationModel = new NotificationOptions
|
var notificationModel = new NotificationOptions
|
||||||
|
@ -39,7 +38,32 @@ namespace Ombi.Core
|
||||||
RequestType = model.RequestType
|
RequestType = model.RequestType
|
||||||
};
|
};
|
||||||
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
|
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.Core.Models.Requests;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Store.Entities.Requests;
|
using Ombi.Store.Entities.Requests;
|
||||||
|
|
||||||
namespace Ombi.Core
|
namespace Ombi.Core
|
||||||
|
@ -7,5 +8,7 @@ namespace Ombi.Core
|
||||||
{
|
{
|
||||||
void NewRequest(FullBaseRequest model);
|
void NewRequest(FullBaseRequest model);
|
||||||
void NewRequest(ChildRequests model);
|
void NewRequest(ChildRequests model);
|
||||||
|
void Notify(MovieRequests model, NotificationType type);
|
||||||
|
void Notify(ChildRequests model, NotificationType type);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
import { Component, OnInit } from "@angular/core";
|
import { PlatformLocation } from "@angular/common";
|
||||||
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||||
|
|
||||||
import { ICustomizationSettings, IEmailNotificationSettings } from "../interfaces";
|
import { ICustomizationSettings, IEmailNotificationSettings } from "../interfaces";
|
||||||
|
@ -15,15 +16,20 @@ export class ResetPasswordComponent implements OnInit {
|
||||||
public form: FormGroup;
|
public form: FormGroup;
|
||||||
public customizationSettings: ICustomizationSettings;
|
public customizationSettings: ICustomizationSettings;
|
||||||
public emailSettings: IEmailNotificationSettings;
|
public emailSettings: IEmailNotificationSettings;
|
||||||
|
public baseUrl: string;
|
||||||
|
|
||||||
constructor(private identityService: IdentityService, private notify: NotificationService,
|
constructor(private identityService: IdentityService, private notify: NotificationService,
|
||||||
private fb: FormBuilder, private settingsService: SettingsService) {
|
private fb: FormBuilder, private settingsService: SettingsService, private location: PlatformLocation) {
|
||||||
this.form = this.fb.group({
|
this.form = this.fb.group({
|
||||||
email: ["", [Validators.required]],
|
email: ["", [Validators.required]],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
|
const base = this.location.getBaseHrefFromDOM();
|
||||||
|
if (base.length > 1) {
|
||||||
|
this.baseUrl = base;
|
||||||
|
}
|
||||||
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
|
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
|
||||||
this.settingsService.getEmailNotificationSettings().subscribe(x => this.emailSettings = x);
|
this.settingsService.getEmailNotificationSettings().subscribe(x => this.emailSettings = x);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Component, Input } from "@angular/core";
|
import { Component, Input } from "@angular/core";
|
||||||
import { IChildRequests, IEpisodesRequests } from "../interfaces";
|
import { IChildRequests } from "../interfaces";
|
||||||
import { NotificationService, RequestService } from "../services";
|
import { NotificationService, RequestService } from "../services";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -31,7 +31,7 @@ export class TvRequestChildrenComponent {
|
||||||
ep.approved = false;
|
ep.approved = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.requestService.updateChild(request)
|
this.requestService.deleteChild(request)
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,23 +55,6 @@ export class TvRequestChildrenComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public denySeasonRequest(request: IChildRequests) {
|
|
||||||
request.approved = false;
|
|
||||||
request.denied = true;
|
|
||||||
this.requestService.updateChild(request)
|
|
||||||
.subscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getColour(ep: IEpisodesRequests): string {
|
|
||||||
if (ep.available) {
|
|
||||||
return "lime";
|
|
||||||
}
|
|
||||||
if (ep.approved) {
|
|
||||||
return "#00c0ff";
|
|
||||||
}
|
|
||||||
return "white";
|
|
||||||
}
|
|
||||||
|
|
||||||
private removeRequestFromUi(key: IChildRequests) {
|
private removeRequestFromUi(key: IChildRequests) {
|
||||||
const index = this.childRequests.indexOf(key, 0);
|
const index = this.childRequests.indexOf(key, 0);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
|
|
|
@ -78,6 +78,12 @@ export class RequestService extends ServiceAuthHelpers {
|
||||||
public updateChild(child: IChildRequests): Observable<IChildRequests> {
|
public updateChild(child: IChildRequests): Observable<IChildRequests> {
|
||||||
return this.http.put(`${this.url}tv/child`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
return this.http.put(`${this.url}tv/child`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||||
}
|
}
|
||||||
|
public denyChild(child: IChildRequests): Observable<IChildRequests> {
|
||||||
|
return this.http.put(`${this.url}tv/deny`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||||
|
}
|
||||||
|
public changeAvailabilityChild(child: IChildRequests): Observable<IChildRequests> {
|
||||||
|
return this.http.put(`${this.url}tv/changeavailability`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||||
|
}
|
||||||
public approveChild(child: IChildRequests): Observable<IRequestEngineResult> {
|
public approveChild(child: IChildRequests): Observable<IRequestEngineResult> {
|
||||||
return this.http.post(`${this.url}tv/child/approve`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
return this.http.post(`${this.url}tv/child/approve`, JSON.stringify(child), { headers: this.headers }).map(this.extractData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,6 +200,28 @@ namespace Ombi.Controllers
|
||||||
return await TvRequestEngine.UpdateChildRequest(child);
|
return await TvRequestEngine.UpdateChildRequest(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Denies the a specific child request
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="child">The model.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut("tv/deny")]
|
||||||
|
public async Task<ChildRequests> DenyChild([FromBody] ChildRequests child)
|
||||||
|
{
|
||||||
|
return await TvRequestEngine.DenyChildRequest(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the availability of the a specific child request
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="child">The model.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPut("tv/changeavailability")]
|
||||||
|
public async Task<ChildRequests> ChangeAvailability([FromBody] ChildRequests child)
|
||||||
|
{
|
||||||
|
return await TvRequestEngine.ChangeAvailability(child);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the a specific child request
|
/// Updates the a specific child request
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue