mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 07:46:05 -07:00
Finished adding subscriptions for TV Shows
This commit is contained in:
parent
7a9fc1213f
commit
16952cb44c
11 changed files with 95 additions and 29 deletions
|
@ -120,12 +120,9 @@ namespace Ombi.Core.Engine
|
||||||
var settings = await Cache.GetOrAdd(CacheKeys.OmbiSettings, async () => await OmbiSettings.GetSettingsAsync());
|
var settings = await Cache.GetOrAdd(CacheKeys.OmbiSettings, async () => await OmbiSettings.GetSettingsAsync());
|
||||||
var result = new HideResult
|
var result = new HideResult
|
||||||
{
|
{
|
||||||
Hide = settings.HideRequestsUsers
|
Hide = settings.HideRequestsUsers,
|
||||||
|
UserId = user.Id
|
||||||
};
|
};
|
||||||
if (settings.HideRequestsUsers)
|
|
||||||
{
|
|
||||||
result.UserId = user.Id;
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,10 +138,10 @@ namespace Ombi.Core.Engine
|
||||||
{
|
{
|
||||||
allRequests = await MovieRepository.GetWithUser().Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
|
allRequests = await MovieRepository.GetWithUser().Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
|
||||||
}
|
}
|
||||||
allRequests.ForEach(x =>
|
allRequests.ForEach(async x =>
|
||||||
{
|
{
|
||||||
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
|
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
|
||||||
CheckForSubscription(shouldHide, x);
|
await CheckForSubscription(shouldHide, x);
|
||||||
});
|
});
|
||||||
return allRequests;
|
return allRequests;
|
||||||
}
|
}
|
||||||
|
@ -176,20 +176,28 @@ namespace Ombi.Core.Engine
|
||||||
allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
allRequests.ForEach(x =>
|
allRequests.ForEach(async x =>
|
||||||
{
|
{
|
||||||
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
|
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
|
||||||
CheckForSubscription(shouldHide, x);
|
await CheckForSubscription(shouldHide, x);
|
||||||
});
|
});
|
||||||
return allRequests;
|
return allRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckForSubscription(HideResult shouldHide, MovieRequests x)
|
private async Task CheckForSubscription(HideResult shouldHide, MovieRequests x)
|
||||||
{
|
{
|
||||||
var sub = _subscriptionRepository.GetAll().FirstOrDefaultAsync(s =>
|
if (shouldHide.UserId == x.RequestedUserId)
|
||||||
|
{
|
||||||
|
x.ShowSubscribe = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x.ShowSubscribe = true;
|
||||||
|
var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s =>
|
||||||
s.UserId == shouldHide.UserId && s.RequestId == x.Id && s.RequestType == RequestType.Movie);
|
s.UserId == shouldHide.UserId && s.RequestId == x.Id && s.RequestType == RequestType.Movie);
|
||||||
x.Subscribed = sub != null;
|
x.Subscribed = sub != null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches the movie request.
|
/// Searches the movie request.
|
||||||
|
@ -209,10 +217,10 @@ namespace Ombi.Core.Engine
|
||||||
allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
||||||
}
|
}
|
||||||
var results = allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToList();
|
var results = allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToList();
|
||||||
results.ForEach(x =>
|
results.ForEach(async x =>
|
||||||
{
|
{
|
||||||
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
|
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
|
||||||
CheckForSubscription(shouldHide, x);
|
await CheckForSubscription(shouldHide, x);
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,8 @@ namespace Ombi.Core.Engine
|
||||||
.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
|
.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
||||||
|
|
||||||
return allRequests;
|
return allRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,25 +184,28 @@ namespace Ombi.Core.Engine
|
||||||
.ThenInclude(x => x.Episodes)
|
.ThenInclude(x => x.Episodes)
|
||||||
.Skip(position).Take(count).ToListAsync();
|
.Skip(position).Take(count).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
||||||
return ParseIntoTreeNode(allRequests);
|
return ParseIntoTreeNode(allRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TvRequests>> GetRequests()
|
public async Task<IEnumerable<TvRequests>> GetRequests()
|
||||||
{
|
{
|
||||||
var shouldHide = await HideFromOtherUsers();
|
var shouldHide = await HideFromOtherUsers();
|
||||||
IQueryable<TvRequests> allRequests;
|
List<TvRequests> allRequests;
|
||||||
if (shouldHide.Hide)
|
if (shouldHide.Hide)
|
||||||
{
|
{
|
||||||
allRequests = TvRepository.Get(shouldHide.UserId);
|
allRequests = await TvRepository.Get(shouldHide.UserId).ToListAsync();
|
||||||
|
|
||||||
FilterChildren(allRequests, shouldHide);
|
FilterChildren(allRequests, shouldHide);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
allRequests = TvRepository.Get();
|
allRequests = await TvRepository.Get().ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
return await allRequests.ToListAsync();
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
||||||
|
return allRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FilterChildren(IEnumerable<TvRequests> allRequests, HideResult shouldHide)
|
private static void FilterChildren(IEnumerable<TvRequests> allRequests, HideResult shouldHide)
|
||||||
|
@ -233,6 +238,8 @@ namespace Ombi.Core.Engine
|
||||||
allRequests = await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync();
|
allRequests = await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
||||||
|
|
||||||
return allRequests;
|
return allRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +256,8 @@ namespace Ombi.Core.Engine
|
||||||
allRequests = TvRepository.Get();
|
allRequests = TvRepository.Get();
|
||||||
}
|
}
|
||||||
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
||||||
|
|
||||||
|
results.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,6 +274,7 @@ namespace Ombi.Core.Engine
|
||||||
allRequests = TvRepository.Get();
|
allRequests = TvRepository.Get();
|
||||||
}
|
}
|
||||||
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
||||||
|
results.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
||||||
return ParseIntoTreeNode(results);
|
return ParseIntoTreeNode(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,6 +456,29 @@ namespace Ombi.Core.Engine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task CheckForSubscription(HideResult shouldHide, TvRequests x)
|
||||||
|
{
|
||||||
|
foreach (var tv in x.ChildRequests)
|
||||||
|
{
|
||||||
|
await CheckForSubscription(shouldHide, tv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CheckForSubscription(HideResult shouldHide, ChildRequests x)
|
||||||
|
{
|
||||||
|
if (shouldHide.UserId == x.RequestedUserId)
|
||||||
|
{
|
||||||
|
x.ShowSubscribe = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x.ShowSubscribe = true;
|
||||||
|
var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s =>
|
||||||
|
s.UserId == shouldHide.UserId && s.RequestId == x.Id && s.RequestType == RequestType.TvShow);
|
||||||
|
x.Subscribed = sub != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<RequestEngineResult> AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest)
|
private async Task<RequestEngineResult> AddExistingRequest(ChildRequests newRequest, TvRequests existingRequest)
|
||||||
{
|
{
|
||||||
// Add the child
|
// Add the child
|
||||||
|
|
|
@ -13,6 +13,15 @@ namespace Ombi.Store.Entities.Requests
|
||||||
public int? IssueId { get; set; }
|
public int? IssueId { get; set; }
|
||||||
public SeriesType SeriesType { get; set; }
|
public SeriesType SeriesType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is to see if the user is subscribed in the UI
|
||||||
|
/// </summary>
|
||||||
|
[NotMapped]
|
||||||
|
public bool Subscribed { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public bool ShowSubscribe { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[ForeignKey(nameof(IssueId))]
|
[ForeignKey(nameof(IssueId))]
|
||||||
public List<Issues> Issues { get; set; }
|
public List<Issues> Issues { get; set; }
|
||||||
|
|
|
@ -14,6 +14,8 @@ namespace Ombi.Store.Entities.Requests
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public bool Subscribed { get; set; }
|
public bool Subscribed { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public bool ShowSubscribe { get; set; }
|
||||||
|
|
||||||
public int RootPathOverride { get; set; }
|
public int RootPathOverride { get; set; }
|
||||||
public int QualityOverride { get; set; }
|
public int QualityOverride { get; set; }
|
||||||
|
|
|
@ -17,11 +17,6 @@ namespace Ombi.Store.Entities.Requests
|
||||||
public DateTime ReleaseDate { get; set; }
|
public DateTime ReleaseDate { get; set; }
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is to see if the user is subscribed in the UI
|
|
||||||
/// </summary>
|
|
||||||
[NotMapped]
|
|
||||||
public bool Subscribed { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is so we can correctly send the right amount of seasons to Sonarr
|
/// This is so we can correctly send the right amount of seasons to Sonarr
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -13,6 +13,7 @@ export interface IMovieRequests extends IFullBaseRequest {
|
||||||
qualityOverride: number;
|
qualityOverride: number;
|
||||||
digitalReleaseDate: Date;
|
digitalReleaseDate: Date;
|
||||||
subscribed: boolean;
|
subscribed: boolean;
|
||||||
|
showSubscribe: boolean;
|
||||||
|
|
||||||
// For the UI
|
// For the UI
|
||||||
rootPathOverrideTitle: string;
|
rootPathOverrideTitle: string;
|
||||||
|
@ -78,6 +79,8 @@ export interface ITvRequests {
|
||||||
|
|
||||||
export interface IChildRequests extends IBaseRequest {
|
export interface IChildRequests extends IBaseRequest {
|
||||||
seasonRequests: INewSeasonRequests[];
|
seasonRequests: INewSeasonRequests[];
|
||||||
|
subscribed: boolean;
|
||||||
|
showSubscribe: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITvUpdateModel {
|
export interface ITvUpdateModel {
|
||||||
|
|
|
@ -128,8 +128,8 @@
|
||||||
|
|
||||||
<div style="float:right">
|
<div style="float:right">
|
||||||
|
|
||||||
<a *ngIf="!request.subscribed" style="color:white" (click)="subscribe(request)" pTooltip="Subscribe for notifications"> <i class="fa fa-rss"></i></a>
|
<a *ngIf="request.showSubscribe && !request.subscribed" style="color:white" (click)="subscribe(request)" pTooltip="Subscribe for notifications"> <i class="fa fa-rss"></i></a>
|
||||||
<a *ngIf="request.subscribed" style="color:red" (click)="unSubscribe(request)" pTooltip="Unsubscribe notification"> <i class="fa fa-rss"></i></a>
|
<a *ngIf="request.showSubscribe && request.subscribed" style="color:red" (click)="unSubscribe(request)" pTooltip="Unsubscribe notification"> <i class="fa fa-rss"></i></a>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="isAdmin">
|
<div *ngIf="isAdmin">
|
||||||
<div *ngIf="!request.approved" id="approveBtn">
|
<div *ngIf="!request.approved" id="approveBtn">
|
||||||
|
|
|
@ -219,7 +219,7 @@ export class MovieRequestsComponent implements OnInit {
|
||||||
|
|
||||||
public unSubscribe(request: IMovieRequests) {
|
public unSubscribe(request: IMovieRequests) {
|
||||||
request.subscribed = false;
|
request.subscribed = false;
|
||||||
this.requestService.subscribeToMovie(request.id)
|
this.requestService.unSubscribeToMovie(request.id)
|
||||||
.subscribe(x => {
|
.subscribe(x => {
|
||||||
this.notificationService.success("Unsubscribed Movie!");
|
this.notificationService.success("Unsubscribed Movie!");
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,8 +11,11 @@
|
||||||
<span *ngIf="isAdmin && !child.requestedUser.alias">{{child.requestedUser.userName}}</span>
|
<span *ngIf="isAdmin && !child.requestedUser.alias">{{child.requestedUser.userName}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-1 col-md-push-9">
|
<div class="col-md-1 col-md-push-9">
|
||||||
|
<button id="subscribeBtn" *ngIf="child.showSubscribe && !child.subscribed" (click)="subscribe(child)" class="btn btn-sm btn-primary-outline" pTooltip="Subscribe for notifications" type="submit"><i class="fa fa-rss"></i> Subscribe</button>
|
||||||
|
<button id="subscribeBtn" *ngIf="child.showSubscribe && child.subscribed" (click)="unSubscribe(child)" class="btn btn-sm btn-danger-outline" pTooltip="UnSubscribe for notifications" type="submit"><i class="fa fa-rss"></i> UnSubscribe</button>
|
||||||
|
|
||||||
|
|
||||||
<div *ngIf="isAdmin">
|
<div *ngIf="isAdmin">
|
||||||
<button id="approveBtn" *ngIf="child.canApprove && !child.approved" (click)="approve(child)" class="btn btn-sm btn-success-outline" type="submit"><i class="fa fa-plus"></i> {{ 'Common.Approve' | translate }}</button>
|
<button id="approveBtn" *ngIf="child.canApprove && !child.approved" (click)="approve(child)" class="btn btn-sm btn-success-outline" type="submit"><i class="fa fa-plus"></i> {{ 'Common.Approve' | translate }}</button>
|
||||||
<button id="unavailableBtn" *ngIf="child.available" (click)="changeAvailability(child, false)" style="text-align: right" value="false" class="btn btn-sm btn-info-outline change"><i class="fa fa-minus"></i> {{ 'Requests.MarkUnavailable' | translate }}</button>
|
<button id="unavailableBtn" *ngIf="child.available" (click)="changeAvailability(child, false)" style="text-align: right" value="false" class="btn btn-sm btn-info-outline change"><i class="fa fa-minus"></i> {{ 'Requests.MarkUnavailable' | translate }}</button>
|
||||||
|
|
|
@ -94,6 +94,22 @@ export class TvRequestChildrenComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public subscribe(request: IChildRequests) {
|
||||||
|
request.subscribed = true;
|
||||||
|
this.requestService.subscribeToTv(request.id)
|
||||||
|
.subscribe(x => {
|
||||||
|
this.notificationService.success("Subscribed To TV Show!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public unSubscribe(request: IChildRequests) {
|
||||||
|
request.subscribed = false;
|
||||||
|
this.requestService.unSubscribeToTv(request.id)
|
||||||
|
.subscribe(x => {
|
||||||
|
this.notificationService.success("Unsubscribed TV Show!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue