Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let users see the full anonymous list of requests added. #4457

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Ombi.Core/Engine/BaseMediaEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ protected async Task<HideResult> HideFromOtherUsers()
var result = new HideResult
{
Hide = settings.HideRequestsUsers,
Anonimize = settings.AnonimizeRequests,
UserId = user.Id
};
return result;
Expand Down Expand Up @@ -245,6 +246,7 @@ protected bool DemoCheck(string title)
public class HideResult
{
public bool Hide { get; set; }
public bool Anonimize { get; set; }
public string UserId { get; set; }
}
}
Expand Down
22 changes: 12 additions & 10 deletions src/Ombi.Core/Engine/MovieRequestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public async Task<RequestsViewModel<MovieRequests>> GetRequests(int count, int p
{
allRequests =
MovieRepository
.GetWithUser(); //.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
.GetWithUser(shouldHide.Anonimize); //.Skip(position).Take(count).OrderByDescending(x => x.ReleaseDate).ToListAsync();
}

switch (orderFilter.AvailabilityFilter)
Expand Down Expand Up @@ -240,8 +240,8 @@ public async Task<RequestsViewModel<MovieRequests>> GetRequests(int count, int p
{
allRequests =
MovieRepository
.GetWithUser();
}
.GetWithUser(shouldHide.Anonimize);
}

var prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(sortProperty, true);

Expand Down Expand Up @@ -284,7 +284,7 @@ public async Task<RequestsViewModel<MovieRequests>> GetRequestsByStatus(int coun
{
allRequests =
MovieRepository
.GetWithUser();
.GetWithUser(shouldHide.Anonimize);
}

switch (status)
Expand Down Expand Up @@ -346,7 +346,7 @@ public async Task<RequestsViewModel<MovieRequests>> GetUnavailableRequests(int c
{
allRequests =
MovieRepository
.GetWithUser().Where(x => !x.Available && x.Approved);
.GetWithUser(shouldHide.Anonimize).Where(x => !x.Available && x.Approved);
}

var prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(sortProperty, true);
Expand Down Expand Up @@ -428,7 +428,7 @@ public async Task<int> GetTotal()
}
else
{
return await MovieRepository.GetWithUser().CountAsync();
return await MovieRepository.GetWithUser(shouldHide.Anonimize).CountAsync();
}
}

Expand All @@ -446,7 +446,7 @@ public async Task<IEnumerable<MovieRequests>> GetRequests()
}
else
{
allRequests = await MovieRepository.GetWithUser().ToListAsync();
allRequests = await MovieRepository.GetWithUser(shouldHide.Anonimize).ToListAsync();
}

await CheckForSubscription(shouldHide, allRequests);
Expand All @@ -456,7 +456,8 @@ public async Task<IEnumerable<MovieRequests>> GetRequests()

public async Task<MovieRequests> GetRequest(int requestId)
{
var request = await MovieRepository.GetWithUser().Where(x => x.Id == requestId).FirstOrDefaultAsync();
var shouldHide = await HideFromOtherUsers();
var request = await MovieRepository.GetWithUser(shouldHide.Anonimize).Where(x => x.Id == requestId).FirstOrDefaultAsync();
await CheckForSubscription(new HideResult(), new List<MovieRequests> { request });

return request;
Expand Down Expand Up @@ -499,7 +500,7 @@ public async Task<IEnumerable<MovieRequests>> SearchMovieRequest(string search)
}
else
{
allRequests = await MovieRepository.GetWithUser().ToListAsync();
allRequests = await MovieRepository.GetWithUser(shouldHide.Anonimize).ToListAsync();
}

var results = allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToList();
Expand Down Expand Up @@ -630,7 +631,8 @@ private async Task<RequestEngineResult> ProcessSendingMovie(MovieRequests reques
/// <returns></returns>
public async Task<MovieRequests> UpdateMovieRequest(MovieRequests request)
{
var allRequests = await MovieRepository.GetWithUser().ToListAsync();
var shouldHide = await HideFromOtherUsers();
var allRequests = await MovieRepository.GetWithUser(shouldHide.Anonimize).ToListAsync();
var results = allRequests.FirstOrDefault(x => x.Id == request.Id);

results.Approved = request.Approved;
Expand Down
3 changes: 2 additions & 1 deletion src/Ombi.Core/Engine/UserStatsEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public UserStatsEngine(IMovieRequestRepository movieRequest, ITvRequestRepositor

public async Task<UserStatsSummary> GetSummary(SummaryRequest request)
{

// get all movie requests
var movies = _movieRequest.GetWithUser();
var movies = _movieRequest.GetWithUser(false);
var filteredMovies = movies.Where(x => x.RequestedDate >= request.From && x.RequestedDate <= request.To);
var tv = _tvRequest.GetLite();
var children = tv.SelectMany(x =>
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Notifications/BaseNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected virtual async Task LoadRequest(int requestId, RequestType type)
{
if (type == RequestType.Movie)
{
MovieRequest = await MovieRepository.GetWithUser().FirstOrDefaultAsync(x => x.Id == requestId);
MovieRequest = await MovieRepository.GetWithUser(false).FirstOrDefaultAsync(x => x.Id == requestId);
}
else if (type == RequestType.TvShow)
{
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Settings/Settings/Models/OmbiSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class OmbiSettings : Settings
public string ApiKey { get; set; }
public bool DoNotSendNotificationsForAutoApprove { get; set; }
public bool HideRequestsUsers { get; set; }
public bool AnonimizeRequests { get; set; }
public bool DisableHealthChecks { get; set; }
public string DefaultLanguageCode { get; set; } = "en";
public bool AutoDeleteAvailableRequests { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IMovieRequestRepository : IRepository<MovieRequests>
Task Update(MovieRequests request);
Task Save();
Task MarkAsAvailable(int id);
IQueryable<MovieRequests> GetWithUser();
IQueryable<MovieRequests> GetWithUser(bool anonimize);
IQueryable<MovieRequests> GetWithUser(string userId);
IQueryable<MovieRequests> GetAll(string userId);
}
Expand Down
17 changes: 12 additions & 5 deletions src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public async Task<MovieRequests> GetRequestAsync(int theMovieDbId)
}

public IQueryable<MovieRequests> GetAll(string userId)
{
return GetWithUser().Where(x => x.RequestedUserId == userId);
{
return GetWithUser(false).Where(x => x.RequestedUserId == userId);
}

public MovieRequests GetRequest(int theMovieDbId)
Expand All @@ -46,12 +46,19 @@ public MovieRequests GetRequest(int theMovieDbId)
.FirstOrDefault();
}

public IQueryable<MovieRequests> GetWithUser()
public IQueryable<MovieRequests> GetWithUser(bool anonimize)
{
return Db.MovieRequests
var allRequests = Db.MovieRequests
.Include(x => x.RequestedUser)
.ThenInclude(x => x.NotificationUserIds)
.AsQueryable();
.ToList();

if (anonimize)
{
allRequests.ForEach(x => x.RequestedUser = null);
maartenheebink marked this conversation as resolved.
Show resolved Hide resolved
allRequests.ForEach(x => x.RequestedUserId = null);
}
return allRequests.AsQueryable();
}

public async Task MarkAsAvailable(int id)
Expand Down
3 changes: 2 additions & 1 deletion src/Ombi/ClientApp/src/app/interfaces/ISettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ISettings } from "./ICommon";
import { ISettings } from "./ICommon";
import { RequestLimitType } from ".";

export interface IExternalSettings extends ISettings {
Expand All @@ -15,6 +15,7 @@ export interface IOmbiSettings extends ISettings {
apiKey: string;
doNotSendNotificationsForAutoApprove: boolean;
hideRequestsUsers: boolean;
anonimizeRequests: boolean;
defaultLanguageCode: string;
disableHealthChecks: boolean;
autoDeleteAvailableRequests: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@
<mat-menu #aboveMenu="matMenu" yPosition="above">
<button id="deleteFabButton" mat-menu-item (click)="bulkDelete()">{{'Requests.RequestPanel.Delete' | translate}}</button>
<button id="approveFabButton" mat-menu-item (click)="bulkApprove()">{{'Requests.RequestPanel.Approve' | translate}}</button>
</mat-menu>
</mat-menu>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
public currentFilter: RequestFilterType = RequestFilterType.All;
public selection = new SelectionModel<IMovieRequests>(true, []);
public userName: string;
public anonimized: boolean = true;

public RequestFilter = RequestFilterType;

Expand All @@ -55,11 +56,11 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
}

public ngOnInit() {
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
this.manageOwnRequests = this.auth.hasRole("ManageOwnRequests")
if (this.isAdmin) {
this.displayedColumns.unshift('select');
}
}
const defaultCount = this.storageService.get(this.storageKeyGridCount);
const defaultSort = this.storageService.get(this.storageKey);
const defaultOrder = this.storageService.get(this.storageKeyOrder);
Expand Down Expand Up @@ -102,7 +103,15 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
// Flip flag to show that loading has finished.
this.isLoadingResults = false;
this.resultsLength = data.total;

if (data.collection.filter(x => x.requestedUserId != null).length > 0 &&
data.collection.filter(x => x.requestedUser != null).length > 0) {
this.anonimized = false;
}
if (this.anonimized) {
this.displayedColumns.forEach((element, index) => {
if (element == 'requestedUser.requestedBy') this.displayedColumns.splice(index, 1);
maartenheebink marked this conversation as resolved.
Show resolved Hide resolved
});
}
return data.collection;
}),
catchError((err) => {
Expand Down Expand Up @@ -199,4 +208,4 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
this.ngAfterViewInit();
})
}
}
}
Loading