#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.

pull/1614/head
Jamie.Rees 7 years ago
parent 2ec87ac3d6
commit 9261232bab

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

@ -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 { ICustomizationSettings, IEmailNotificationSettings } from "../interfaces";
@ -15,15 +16,20 @@ export class ResetPasswordComponent implements OnInit {
public form: FormGroup;
public customizationSettings: ICustomizationSettings;
public emailSettings: IEmailNotificationSettings;
public baseUrl: string;
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({
email: ["", [Validators.required]],
});
}
public ngOnInit() {
const base = this.location.getBaseHrefFromDOM();
if (base.length > 1) {
this.baseUrl = base;
}
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
this.settingsService.getEmailNotificationSettings().subscribe(x => this.emailSettings = x);
}

@ -1,5 +1,5 @@
import { Component, Input } from "@angular/core";
import { IChildRequests, IEpisodesRequests } from "../interfaces";
import { IChildRequests } from "../interfaces";
import { NotificationService, RequestService } from "../services";
@Component({
@ -31,7 +31,7 @@ export class TvRequestChildrenComponent {
ep.approved = false;
});
});
this.requestService.updateChild(request)
this.requestService.deleteChild(request)
.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) {
const index = this.childRequests.indexOf(key, 0);
if (index > -1) {

@ -78,6 +78,12 @@ export class RequestService extends ServiceAuthHelpers {
public updateChild(child: IChildRequests): Observable<IChildRequests> {
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> {
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);
}
/// <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>
/// Updates the a specific child request
/// </summary>

Loading…
Cancel
Save