diff --git a/src/Ombi.Core/Engine/BaseMediaEngine.cs b/src/Ombi.Core/Engine/BaseMediaEngine.cs index 277144ab1..0498bf58d 100644 --- a/src/Ombi.Core/Engine/BaseMediaEngine.cs +++ b/src/Ombi.Core/Engine/BaseMediaEngine.cs @@ -157,6 +157,7 @@ namespace Ombi.Core.Engine var result = new HideResult { Hide = settings.HideRequestsUsers, + Anonimize = settings.AnonimizeRequests, UserId = user.Id }; return result; @@ -245,6 +246,7 @@ namespace Ombi.Core.Engine public class HideResult { public bool Hide { get; set; } + public bool Anonimize { get; set; } public string UserId { get; set; } } } diff --git a/src/Ombi.Core/Engine/MovieRequestEngine.cs b/src/Ombi.Core/Engine/MovieRequestEngine.cs index f69e890be..e2276eb52 100644 --- a/src/Ombi.Core/Engine/MovieRequestEngine.cs +++ b/src/Ombi.Core/Engine/MovieRequestEngine.cs @@ -179,7 +179,7 @@ namespace Ombi.Core.Engine { 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) @@ -240,8 +240,8 @@ namespace Ombi.Core.Engine { allRequests = MovieRepository - .GetWithUser(); - } + .GetWithUser(shouldHide.Anonimize); + } var prop = TypeDescriptor.GetProperties(typeof(MovieRequests)).Find(sortProperty, true); @@ -284,7 +284,7 @@ namespace Ombi.Core.Engine { allRequests = MovieRepository - .GetWithUser(); + .GetWithUser(shouldHide.Anonimize); } switch (status) @@ -346,7 +346,7 @@ namespace Ombi.Core.Engine { 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); @@ -428,7 +428,7 @@ namespace Ombi.Core.Engine } else { - return await MovieRepository.GetWithUser().CountAsync(); + return await MovieRepository.GetWithUser(shouldHide.Anonimize).CountAsync(); } } @@ -446,7 +446,7 @@ namespace Ombi.Core.Engine } else { - allRequests = await MovieRepository.GetWithUser().ToListAsync(); + allRequests = await MovieRepository.GetWithUser(shouldHide.Anonimize).ToListAsync(); } await CheckForSubscription(shouldHide, allRequests); @@ -456,7 +456,8 @@ namespace Ombi.Core.Engine public async Task 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 { request }); return request; @@ -499,7 +500,7 @@ namespace Ombi.Core.Engine } 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(); @@ -630,7 +631,8 @@ namespace Ombi.Core.Engine /// public async Task 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; diff --git a/src/Ombi.Core/Engine/UserStatsEngine.cs b/src/Ombi.Core/Engine/UserStatsEngine.cs index 6b26591f4..6d2e29597 100644 --- a/src/Ombi.Core/Engine/UserStatsEngine.cs +++ b/src/Ombi.Core/Engine/UserStatsEngine.cs @@ -23,8 +23,9 @@ namespace Ombi.Core.Engine public async Task 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 => diff --git a/src/Ombi.Notifications/BaseNotification.cs b/src/Ombi.Notifications/BaseNotification.cs index ac9de5736..092b2766d 100644 --- a/src/Ombi.Notifications/BaseNotification.cs +++ b/src/Ombi.Notifications/BaseNotification.cs @@ -139,7 +139,7 @@ namespace Ombi.Notifications { 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) { diff --git a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs index ba460a2bd..c6c0eb58f 100644 --- a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs +++ b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs @@ -8,6 +8,7 @@ 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; } diff --git a/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs b/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs index 5c44b2d6c..04c13a574 100644 --- a/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs @@ -11,7 +11,7 @@ namespace Ombi.Store.Repository.Requests Task Update(MovieRequests request); Task Save(); Task MarkAsAvailable(int id); - IQueryable GetWithUser(); + IQueryable GetWithUser(bool anonimize); IQueryable GetWithUser(string userId); IQueryable GetAll(string userId); } diff --git a/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs b/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs index bbf52c7f0..739fce105 100644 --- a/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs @@ -35,8 +35,8 @@ namespace Ombi.Store.Repository.Requests } public IQueryable GetAll(string userId) - { - return GetWithUser().Where(x => x.RequestedUserId == userId); + { + return GetWithUser(false).Where(x => x.RequestedUserId == userId); } public MovieRequests GetRequest(int theMovieDbId) @@ -46,12 +46,19 @@ namespace Ombi.Store.Repository.Requests .FirstOrDefault(); } - public IQueryable GetWithUser() + public IQueryable 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); + allRequests.ForEach(x => x.RequestedUserId = null); + } + return allRequests.AsQueryable(); } public async Task MarkAsAvailable(int id) diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts index c5dcaffc6..4f9b16a13 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts @@ -1,4 +1,4 @@ -import { ISettings } from "./ICommon"; +import { ISettings } from "./ICommon"; import { RequestLimitType } from "."; export interface IExternalSettings extends ISettings { @@ -15,6 +15,7 @@ export interface IOmbiSettings extends ISettings { apiKey: string; doNotSendNotificationsForAutoApprove: boolean; hideRequestsUsers: boolean; + anonimizeRequests: boolean; defaultLanguageCode: string; disableHealthChecks: boolean; autoDeleteAvailableRequests: boolean; diff --git a/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.html b/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.html index 61baa3eaa..7143a90b6 100644 --- a/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.html +++ b/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.html @@ -92,4 +92,4 @@ - \ No newline at end of file + diff --git a/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.ts b/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.ts index 111c299c5..7e370b1f4 100644 --- a/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.ts +++ b/src/Ombi/ClientApp/src/app/requests-list/components/movies-grid/movies-grid.component.ts @@ -32,6 +32,7 @@ export class MoviesGridComponent implements OnInit, AfterViewInit { public currentFilter: RequestFilterType = RequestFilterType.All; public selection = new SelectionModel(true, []); public userName: string; + public anonimized: boolean = true; public RequestFilter = RequestFilterType; @@ -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); @@ -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); + }); + } return data.collection; }), catchError((err) => { @@ -199,4 +208,4 @@ export class MoviesGridComponent implements OnInit, AfterViewInit { this.ngAfterViewInit(); }) } -} \ No newline at end of file +} diff --git a/src/Ombi/ClientApp/src/app/settings/ombi/ombi.component.html b/src/Ombi/ClientApp/src/app/settings/ombi/ombi.component.html index a575c24a7..042028e51 100644 --- a/src/Ombi/ClientApp/src/app/settings/ombi/ombi.component.html +++ b/src/Ombi/ClientApp/src/app/settings/ombi/ombi.component.html @@ -1,85 +1,91 @@ - +
Ombi Configuration
-
-
- - Base URL - - -
-
- - Api Key - - - - -
-
- - - - Stable - - - Develop - - - -
-
- - Do not send Notifications if a User has the Auto Approve permission -
-
- - Hide requests from other users - -
-
- - Auto Delete Available Requests - -
-
- - Delete After Days of Availbility - - -
-
- - Allow us to collect anonymous analytical data e.g. browser used - -
- -
- - - -- - - {{lang.nativeName}} - - - -
-
-
- -
-
+
+
+ + Base URL + +
+
+ + Api Key + + + + +
+
+ + + + Stable + + + Develop + + + +
+
+ + Do not send Notifications if a User has the Auto Approve permission + +
+
+ + Hide requests from other users + +
+
+ + Anonimize requests for other users + +
+
+ + Auto Delete Available Requests + +
+
+ + Delete After Days of Availbility + + +
+
+ + Allow us to collect anonymous analytical data e.g. browser used + +
+ +
+ + + -- + + {{lang.nativeName}} + + + +
+
+
+ +
+
+
-
\ No newline at end of file + diff --git a/src/Ombi/ClientApp/src/app/settings/ombi/ombi.component.ts b/src/Ombi/ClientApp/src/app/settings/ombi/ombi.component.ts index f797703bc..59d935ba7 100644 --- a/src/Ombi/ClientApp/src/app/settings/ombi/ombi.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/ombi/ombi.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from "@angular/core"; +import { Component, OnInit } from "@angular/core"; import { FormBuilder, FormGroup } from "@angular/forms"; import { Branch, ILanguageRefine, IOmbiSettings } from "../../interfaces"; @@ -29,6 +29,7 @@ export class OmbiComponent implements OnInit { baseUrl: [x.baseUrl], doNotSendNotificationsForAutoApprove: [x.doNotSendNotificationsForAutoApprove], hideRequestsUsers: [x.hideRequestsUsers], + anonimizeRequests: [x.anonimizeRequests], defaultLanguageCode: [x.defaultLanguageCode], disableHealthChecks: [x.disableHealthChecks], autoDeleteAvailableRequests: [x.autoDeleteAvailableRequests],