mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-22 14:13:36 -07:00
hide the username when the hide requests is set
This commit is contained in:
parent
cb57553f52
commit
55e16e9e28
4 changed files with 43 additions and 12 deletions
|
@ -1,6 +1,11 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Ombi.Core.Authentication;
|
||||||
|
using Ombi.Core.Engine.Interfaces;
|
||||||
|
using Ombi.Core.Helpers;
|
||||||
using Ombi.Core.Models.Requests;
|
using Ombi.Core.Models.Requests;
|
||||||
|
using Ombi.Core.Rule.Interfaces;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Settings.Settings.Models;
|
using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository.Requests;
|
using Ombi.Store.Repository.Requests;
|
||||||
|
@ -10,15 +15,17 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using static Ombi.Core.Engine.BaseMediaEngine;
|
||||||
|
|
||||||
namespace Ombi.Core.Services
|
namespace Ombi.Core.Services
|
||||||
{
|
{
|
||||||
public class RecentlyRequestedService : IRecentlyRequestedService
|
public class RecentlyRequestedService : BaseEngine, IRecentlyRequestedService
|
||||||
{
|
{
|
||||||
private readonly IMovieRequestRepository _movieRequestRepository;
|
private readonly IMovieRequestRepository _movieRequestRepository;
|
||||||
private readonly ITvRequestRepository _tvRequestRepository;
|
private readonly ITvRequestRepository _tvRequestRepository;
|
||||||
private readonly IMusicRequestRepository _musicRequestRepository;
|
private readonly IMusicRequestRepository _musicRequestRepository;
|
||||||
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
|
private readonly ISettingsService<CustomizationSettings> _customizationSettings;
|
||||||
|
private readonly ISettingsService<OmbiSettings> _ombiSettings;
|
||||||
|
|
||||||
private const int AmountToTake = 7;
|
private const int AmountToTake = 7;
|
||||||
|
|
||||||
|
@ -26,12 +33,17 @@ namespace Ombi.Core.Services
|
||||||
IMovieRequestRepository movieRequestRepository,
|
IMovieRequestRepository movieRequestRepository,
|
||||||
ITvRequestRepository tvRequestRepository,
|
ITvRequestRepository tvRequestRepository,
|
||||||
IMusicRequestRepository musicRequestRepository,
|
IMusicRequestRepository musicRequestRepository,
|
||||||
ISettingsService<CustomizationSettings> customizationSettings)
|
ISettingsService<CustomizationSettings> customizationSettings,
|
||||||
|
ISettingsService<OmbiSettings> ombiSettings,
|
||||||
|
ICurrentUser user,
|
||||||
|
OmbiUserManager um,
|
||||||
|
IRuleEvaluator rules) : base(user, um, rules)
|
||||||
{
|
{
|
||||||
_movieRequestRepository = movieRequestRepository;
|
_movieRequestRepository = movieRequestRepository;
|
||||||
_tvRequestRepository = tvRequestRepository;
|
_tvRequestRepository = tvRequestRepository;
|
||||||
_musicRequestRepository = musicRequestRepository;
|
_musicRequestRepository = musicRequestRepository;
|
||||||
_customizationSettings = customizationSettings;
|
_customizationSettings = customizationSettings;
|
||||||
|
_ombiSettings = ombiSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<RecentlyRequestedModel>> GetRecentlyRequested(CancellationToken cancellationToken)
|
public async Task<IEnumerable<RecentlyRequestedModel>> GetRecentlyRequested(CancellationToken cancellationToken)
|
||||||
|
@ -49,6 +61,7 @@ namespace Ombi.Core.Services
|
||||||
recentTvRequests = recentTvRequests.Where(x => !x.Available);
|
recentTvRequests = recentTvRequests.Where(x => !x.Available);
|
||||||
recentMusicRequests = recentMusicRequests.Where(x => !x.Available);
|
recentMusicRequests = recentMusicRequests.Where(x => !x.Available);
|
||||||
}
|
}
|
||||||
|
var hideUsers = await HideFromOtherUsers();
|
||||||
|
|
||||||
var model = new List<RecentlyRequestedModel>();
|
var model = new List<RecentlyRequestedModel>();
|
||||||
|
|
||||||
|
@ -64,8 +77,8 @@ namespace Ombi.Core.Services
|
||||||
Title = item.Title,
|
Title = item.Title,
|
||||||
Type = RequestType.Movie,
|
Type = RequestType.Movie,
|
||||||
Approved = item.Approved,
|
Approved = item.Approved,
|
||||||
UserId = item.RequestedUserId,
|
UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId,
|
||||||
Username = item.RequestedUser.UserAlias,
|
Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias,
|
||||||
MediaId = item.TheMovieDbId.ToString(),
|
MediaId = item.TheMovieDbId.ToString(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -82,8 +95,8 @@ namespace Ombi.Core.Services
|
||||||
RequestDate = item.RequestedDate,
|
RequestDate = item.RequestedDate,
|
||||||
Title = item.Title,
|
Title = item.Title,
|
||||||
Type = RequestType.Album,
|
Type = RequestType.Album,
|
||||||
UserId = item.RequestedUserId,
|
UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId,
|
||||||
Username = item.RequestedUser.UserAlias,
|
Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias,
|
||||||
MediaId = item.ForeignAlbumId,
|
MediaId = item.ForeignAlbumId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -102,13 +115,32 @@ namespace Ombi.Core.Services
|
||||||
TvPartiallyAvailable = partialAvailability,
|
TvPartiallyAvailable = partialAvailability,
|
||||||
Title = item.ParentRequest.Title,
|
Title = item.ParentRequest.Title,
|
||||||
Type = RequestType.TvShow,
|
Type = RequestType.TvShow,
|
||||||
UserId = item.RequestedUserId,
|
UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId,
|
||||||
Username = item.RequestedUser.UserAlias,
|
Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias,
|
||||||
MediaId = item.ParentRequest.ExternalProviderId.ToString()
|
MediaId = item.ParentRequest.ExternalProviderId.ToString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return model.OrderByDescending(x => x.RequestDate);
|
return model.OrderByDescending(x => x.RequestDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<HideResult> HideFromOtherUsers()
|
||||||
|
{
|
||||||
|
var user = await GetUser();
|
||||||
|
if (await IsInRole(OmbiRoles.Admin) || await IsInRole(OmbiRoles.PowerUser) || user.IsSystemUser)
|
||||||
|
{
|
||||||
|
return new HideResult
|
||||||
|
{
|
||||||
|
UserId = user.Id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var settings = await _ombiSettings.GetSettingsAsync();
|
||||||
|
var result = new HideResult
|
||||||
|
{
|
||||||
|
Hide = settings.HideRequestsUsers,
|
||||||
|
UserId = user.Id
|
||||||
|
};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<div class="text-right year"><sup>{{request.releaseDate | date:'yyyy'}}</sup></div>
|
<div class="text-right year"><sup>{{request.releaseDate | date:'yyyy'}}</sup></div>
|
||||||
<h3>{{request.title}}</h3>
|
<h3>{{request.title}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12" *ngIf="request.username">
|
||||||
<p>Requested By: {{request.username}}</p>
|
<p>Requested By: {{request.username}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
|
@ -102,6 +102,6 @@ export class RequestServiceV2 extends ServiceHelpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getRecentlyRequested(): Observable<IRecentlyRequested[]> {
|
public getRecentlyRequested(): Observable<IRecentlyRequested[]> {
|
||||||
return this.http.get<IRecentlyRequested[]>(`${this.url}recentlyRequestedstuff`, { headers: this.headers });
|
return this.http.get<IRecentlyRequested[]>(`${this.url}recentlyRequested`, { headers: this.headers });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,8 +227,7 @@ namespace Ombi.Controllers.V2
|
||||||
return await _movieRequestEngine.RequestCollection(collectionId, HttpContext.RequestAborted);
|
return await _movieRequestEngine.RequestCollection(collectionId, HttpContext.RequestAborted);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("recentlyRequestedstuff")]
|
[HttpGet("recentlyRequested")]
|
||||||
[Admin]
|
|
||||||
public Task<IEnumerable<RecentlyRequestedModel>> RecentlyRequested()
|
public Task<IEnumerable<RecentlyRequestedModel>> RecentlyRequested()
|
||||||
{
|
{
|
||||||
return _recentlyRequestedService.GetRecentlyRequested(CancellationToken);
|
return _recentlyRequestedService.GetRecentlyRequested(CancellationToken);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue