diff --git a/src/Ombi.Core.Tests/Services/RecentlyRequestedServiceTests.cs b/src/Ombi.Core.Tests/Services/RecentlyRequestedServiceTests.cs index 018ee99e9..7e1046ca5 100644 --- a/src/Ombi.Core.Tests/Services/RecentlyRequestedServiceTests.cs +++ b/src/Ombi.Core.Tests/Services/RecentlyRequestedServiceTests.cs @@ -182,20 +182,25 @@ namespace Ombi.Core.Tests.Services var releaseDate = new DateTime(2019, 01, 01); var requestDate = DateTime.Now; - var movies = _fixture.CreateMany(10); + var movies = _fixture.CreateMany(10).ToList(); var albums = _fixture.CreateMany(10); var chilRequests = _fixture.CreateMany(10); + movies.Add(_fixture.Build().With(x => x.RequestedUserId, "a").With(x => x.Title, "unit").Create()); _mocker.Setup>(x => x.GetAll()).Returns(movies.AsQueryable().BuildMock()); _mocker.Setup>(x => x.GetAll()).Returns(albums.AsQueryable().BuildMock()); _mocker.Setup>(x => x.GetChild()).Returns(chilRequests.AsQueryable().BuildMock()); - _mocker.Setup>(x => x.GetUser()).ReturnsAsync(new OmbiUser { UserName = "test", Alias = "alias", UserType = UserType.LocalUser }); + _mocker.Setup>(x => x.GetUser()).ReturnsAsync(new OmbiUser { UserName = "test", Id = "a", Alias = "alias", UserType = UserType.LocalUser }); _mocker.Setup(x => x.Username).Returns("test"); _mocker.Setup>(x => x.IsInRoleAsync(It.IsAny(), It.IsAny())).ReturnsAsync(false); var result = await _subject.GetRecentlyRequested(CancellationToken.None); - CollectionAssert.IsEmpty(result.Where(x => !string.IsNullOrEmpty(x.Username) && !string.IsNullOrEmpty(x.UserId))); + Assert.Multiple(() => + { + Assert.That(result.Count, Is.EqualTo(1)); + Assert.That(result.First().Title, Is.EqualTo("unit")); + }); } } } diff --git a/src/Ombi.Core/Services/RecentlyRequestedService.cs b/src/Ombi.Core/Services/RecentlyRequestedService.cs index 1c67472d4..6628dd8b8 100644 --- a/src/Ombi.Core/Services/RecentlyRequestedService.cs +++ b/src/Ombi.Core/Services/RecentlyRequestedService.cs @@ -73,6 +73,10 @@ namespace Ombi.Core.Services var lang = await DefaultLanguageCode(); foreach (var item in await recentMovieRequests.ToListAsync(cancellationToken)) { + if (hideUsers.Hide && item.RequestedUserId != hideUsers.UserId) + { + continue; + } var images = await _cache.GetOrAddAsync($"{CacheKeys.TmdbImages}movie{item.TheMovieDbId}", () => _movieDbApi.GetMovieImages(item.TheMovieDbId.ToString(), cancellationToken), DateTimeOffset.Now.AddDays(1)); model.Add(new RecentlyRequestedModel { @@ -84,8 +88,8 @@ namespace Ombi.Core.Services Title = item.Title, Type = RequestType.Movie, Approved = item.Approved, - UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId, - Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias, + UserId = item.RequestedUserId, + Username = item.RequestedUser.UserAlias, MediaId = item.TheMovieDbId.ToString(), PosterPath = images?.posters?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(), Background = images?.backdrops?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(), @@ -94,6 +98,10 @@ namespace Ombi.Core.Services foreach (var item in await recentMusicRequests.ToListAsync(cancellationToken)) { + if (hideUsers.Hide && item.RequestedUserId != hideUsers.UserId) + { + continue; + } model.Add(new RecentlyRequestedModel { RequestId = item.Id, @@ -104,14 +112,18 @@ namespace Ombi.Core.Services RequestDate = item.RequestedDate, Title = item.Title, Type = RequestType.Album, - UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId, - Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias, + UserId = item.RequestedUserId, + Username = item.RequestedUser.UserAlias, MediaId = item.ForeignAlbumId, }); } foreach (var item in await recentTvRequests.ToListAsync(cancellationToken)) { + if (hideUsers.Hide && item.RequestedUserId != hideUsers.UserId) + { + continue; + } var providerId = item.ParentRequest.ExternalProviderId.ToString(); var images = await _cache.GetOrAddAsync($"{CacheKeys.TmdbImages}tv{providerId}", () => _movieDbApi.GetTvImages(providerId.ToString(), cancellationToken), DateTimeOffset.Now.AddDays(1)); @@ -127,8 +139,8 @@ namespace Ombi.Core.Services TvPartiallyAvailable = partialAvailability, Title = item.ParentRequest.Title, Type = RequestType.TvShow, - UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId, - Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias, + UserId = item.RequestedUserId, + Username = item.RequestedUser.UserAlias, MediaId = providerId.ToString(), PosterPath = images?.posters?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(), Background = images?.backdrops?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(), diff --git a/src/Ombi/ClientApp/src/app/app.module.ts b/src/Ombi/ClientApp/src/app/app.module.ts index 7e12d7b9b..c4547ffe2 100644 --- a/src/Ombi/ClientApp/src/app/app.module.ts +++ b/src/Ombi/ClientApp/src/app/app.module.ts @@ -1,5 +1,5 @@ import { APP_BASE_HREF, CommonModule, PlatformLocation } from "@angular/common"; -import { CustomPageService, ImageService, RequestService, SettingsService, SonarrService } from "./services"; +import { CustomPageService, ImageService, LidarrService, RequestService, SettingsService, SonarrService } from "./services"; import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { HTTP_INTERCEPTORS, HttpClient, HttpClientModule } from "@angular/common/http"; import { IdentityService, IssuesService, JobService, MessageService, PlexTvService, SearchService, StatusService } from "./services"; @@ -209,6 +209,7 @@ export function JwtTokenGetter() { StorageService, RequestService, SonarrService, + LidarrService, SignalRNotificationService, FEATURES_INITIALIZER, SONARR_INITIALIZER, diff --git a/src/Ombi/ClientApp/src/app/discover/components/carousel-list/carousel-list.component.ts b/src/Ombi/ClientApp/src/app/discover/components/carousel-list/carousel-list.component.ts index 43cde5036..2aacd4bd6 100644 --- a/src/Ombi/ClientApp/src/app/discover/components/carousel-list/carousel-list.component.ts +++ b/src/Ombi/ClientApp/src/app/discover/components/carousel-list/carousel-list.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, ViewChild, Output, EventEmitter } from "@angular/core"; +import { Component, OnInit, Input, ViewChild, Output, EventEmitter, Inject } from "@angular/core"; import { DiscoverOption, IDiscoverCardResult } from "../../interfaces"; import { ISearchMovieResult, ISearchTvResult, RequestType } from "../../../interfaces"; import { SearchV2Service } from "../../../services"; @@ -6,6 +6,7 @@ import { StorageService } from "../../../shared/storage/storage-service"; import { MatButtonToggleChange } from '@angular/material/button-toggle'; import { Carousel } from 'primeng/carousel'; import { FeaturesFacade } from "../../../state/features/features.facade"; +import { APP_BASE_HREF } from "@angular/common"; export enum DiscoverType { Upcoming, @@ -44,10 +45,18 @@ export class CarouselListComponent implements OnInit { }; private amountToLoad = 17; private currentlyLoaded = 0; + private baseUrl: string = ""; + constructor(private searchService: SearchV2Service, private storageService: StorageService, - private featureFacade: FeaturesFacade) { + private featureFacade: FeaturesFacade, + @Inject(APP_BASE_HREF) private href: string) { + + if (this.href.length > 1) { + this.baseUrl = this.href; + } + Carousel.prototype.onTouchMove = () => { }, this.responsiveOptions = [ { @@ -294,7 +303,7 @@ export class CarouselListComponent implements OnInit { this.movies.forEach(m => { tempResults.push({ available: m.available, - posterPath: m.posterPath ? `https://image.tmdb.org/t/p/w500/${m.posterPath}` : "../../../images/default_movie_poster.png", + posterPath: m.posterPath ? `https://image.tmdb.org/t/p/w500/${m.posterPath}` : this.baseUrl + "/images/default_movie_poster.png", requested: m.requested, title: m.title, type: RequestType.movie, @@ -316,7 +325,7 @@ export class CarouselListComponent implements OnInit { this.tvShows.forEach(m => { tempResults.push({ available: m.fullyAvailable, - posterPath: m.backdropPath ? `https://image.tmdb.org/t/p/w500/${m.backdropPath}` : "../../../images/default_tv_poster.png", + posterPath: m.backdropPath ? `https://image.tmdb.org/t/p/w500/${m.backdropPath}` : this.baseUrl + "/images/default_tv_poster.png", requested: m.requested, title: m.title, type: RequestType.tvShow, diff --git a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.html b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.html index f35a8f612..e74c8d995 100644 --- a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.html +++ b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.html @@ -84,7 +84,7 @@ {{ 'NavigationBar.Filter.TvShows' | translate}} - {{ 'NavigationBar.Filter.Music' | translate}}