diff --git a/src/Ombi.Core.Tests/Engine/V2/MovieRequestEngineTests.cs b/src/Ombi.Core.Tests/Engine/V2/MovieRequestEngineTests.cs index 3c651b167..c17ac6dfe 100644 --- a/src/Ombi.Core.Tests/Engine/V2/MovieRequestEngineTests.cs +++ b/src/Ombi.Core.Tests/Engine/V2/MovieRequestEngineTests.cs @@ -51,7 +51,7 @@ namespace Ombi.Core.Tests.Engine.V2 [Ignore("Needs to be tested")] public async Task Get_UnavailableRequests() { - _movieRequestRepository.Setup(x => x.GetWithUser()).Returns(new List + _movieRequestRepository.Setup(x => x.GetWithUser(false)).Returns(new List { new MovieRequests { 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/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index edfa7b392..28e70315f 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -369,7 +369,7 @@ namespace Ombi.Core.Engine } else { - allRequests = await TvRepository.GetChild().ToListAsync(); + allRequests = await TvRepository.GetChild(shouldHide.Anonimize).ToListAsync(); } @@ -424,7 +424,7 @@ namespace Ombi.Core.Engine } else { - allRequests = await TvRepository.GetChild().ToListAsync(); + allRequests = await TvRepository.GetChild(shouldHide.Anonimize).ToListAsync(); } 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 b52f0a0cd..333ea5b41 100644 --- a/src/Ombi.Notifications/BaseNotification.cs +++ b/src/Ombi.Notifications/BaseNotification.cs @@ -145,7 +145,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.Schedule/Jobs/Ombi/AutoDeleteRequests.cs b/src/Ombi.Schedule/Jobs/Ombi/AutoDeleteRequests.cs index a2a7e4ed1..eba3c4998 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/AutoDeleteRequests.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/AutoDeleteRequests.cs @@ -25,7 +25,7 @@ namespace Ombi.Schedule.Jobs.Ombi _ombiSettings = ombiSettings; _movieRequests = movieRequest; _tvRequestRepository = tvRequestRepository; - _musicRequestRepository = _musicRequestRepository; + _musicRequestRepository = musicRequestRepository; _logger = logger; } diff --git a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs index e224b5c70..89d3412f2 100644 --- a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs +++ b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs @@ -11,6 +11,7 @@ namespace Ombi.Settings.Settings.Models 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 { diff --git a/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs b/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs index 5c44b2d6c..9230684cc 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 = false); IQueryable GetWithUser(string userId); IQueryable GetAll(string userId); } diff --git a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs index d7106c086..46d50e859 100644 --- a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs @@ -19,7 +19,7 @@ namespace Ombi.Store.Repository.Requests TvRequests GetRequest(int theMovieDbId); Task Update(TvRequests request); Task UpdateChild(ChildRequests request); - IQueryable GetChild(); + IQueryable GetChild(bool anonimize = false); IQueryable GetChild(string userId); Task MarkEpisodeAsAvailable(int id); Task MarkChildAsAvailable(int id); diff --git a/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs b/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs index bbf52c7f0..b47eabf49 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,18 @@ namespace Ombi.Store.Repository.Requests .FirstOrDefault(); } - public IQueryable GetWithUser() + public IQueryable GetWithUser(bool anonimize = false) { - return Db.MovieRequests - .Include(x => x.RequestedUser) - .ThenInclude(x => x.NotificationUserIds) - .AsQueryable(); + if (!anonimize) + { + return Db.MovieRequests + .Include(x => x.RequestedUser) + .ThenInclude(x => x.NotificationUserIds) + .AsQueryable(); + } else + { + return Db.MovieRequests.AsNoTracking().AsQueryable(); + } } public async Task MarkAsAvailable(int id) diff --git a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs index 0a72b1b32..a9f0b441d 100644 --- a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs @@ -80,14 +80,25 @@ namespace Ombi.Store.Repository.Requests .AsQueryable(); } - public IQueryable GetChild() + public IQueryable GetChild(bool anonimize = false) { - return Db.ChildRequests - .Include(x => x.RequestedUser) - .Include(x => x.ParentRequest) - .Include(x => x.SeasonRequests) - .ThenInclude(x => x.Episodes) - .AsQueryable(); + if (!anonimize) { + return Db.ChildRequests + .Include(x => x.RequestedUser) + .Include(x => x.ParentRequest) + .Include(x => x.SeasonRequests) + .ThenInclude(x => x.Episodes) + .AsQueryable(); + } + else + { + return Db.ChildRequests + .AsNoTracking() + .Include(x => x.ParentRequest) + .Include(x => x.SeasonRequests) + .ThenInclude(x => x.Episodes) + .AsQueryable(); + } } public IQueryable GetChild(string userId) diff --git a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts index c7990215f..f4934ad49 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/ISettings.ts @@ -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..8a9f1aec0 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,18 @@ 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 +211,4 @@ export class MoviesGridComponent implements OnInit, AfterViewInit { this.ngAfterViewInit(); }) } -} \ No newline at end of file +} diff --git a/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.ts b/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.ts index 5e8521302..767a16d0e 100644 --- a/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.ts +++ b/src/Ombi/ClientApp/src/app/requests-list/components/tv-grid/tv-grid.component.ts @@ -25,6 +25,7 @@ export class TvGridComponent implements OnInit, AfterViewInit { public defaultSort: string = "requestedDate"; public defaultOrder: string = "desc"; public currentFilter: RequestFilterType = RequestFilterType.All; + public anonimized: boolean = true; public RequestFilter = RequestFilterType; public manageOwnRequests: boolean; @@ -90,6 +91,16 @@ export class TvGridComponent implements OnInit, AfterViewInit { this.isLoadingResults = false; this.resultsLength = data.total; + if (data.collection.filter(x => x.requestedUser != null).length > 0) { + this.anonimized = false; + } + + if (this.anonimized) { + this.displayedColumns.forEach((element, index) => { + if (element == 'requestedBy') this.displayedColumns.splice(index, 1); + }); + } + return data.collection; }), catchError((err) => { 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..181d65fa9 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],