From 42f48caf3b60d793118d70bf0245dd22bf3083c1 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 1 Sep 2017 22:41:56 +0100 Subject: [PATCH] Fixed a bunch of bugs in Ombi #865 --- src/Ombi.Core/Engine/MovieSearchEngine.cs | 10 +++---- .../Templates/BasicTemplate.html | 2 -- .../Jobs/Plex/PlexAvailabilityChecker.cs | 30 +++++++++++++++++-- src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs | 2 +- src/Ombi.Schedule/Ombi.Schedule.csproj | 1 + src/Ombi/ClientApp/app/auth/auth.service.ts | 2 +- .../app/search/moviesearch.component.html | 2 +- .../landingpage/landingpage.component.html | 4 +-- .../app/settings/radarr/radarr.component.html | 2 +- 9 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/Ombi.Core/Engine/MovieSearchEngine.cs b/src/Ombi.Core/Engine/MovieSearchEngine.cs index f4d5230fd..033efcaf9 100644 --- a/src/Ombi.Core/Engine/MovieSearchEngine.cs +++ b/src/Ombi.Core/Engine/MovieSearchEngine.cs @@ -63,7 +63,7 @@ namespace Ombi.Core.Engine if (result != null) { Logger.LogDebug("Search Result: {result}", result); - return await TransformMovieResultsToResponse(result); + return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API } } @@ -81,7 +81,7 @@ namespace Ombi.Core.Engine if (result != null) { Logger.LogDebug("Search Result: {result}", result); - return await TransformMovieResultsToResponse(result); + return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API } return null; } @@ -96,7 +96,7 @@ namespace Ombi.Core.Engine if (result != null) { Logger.LogDebug("Search Result: {result}", result); - return await TransformMovieResultsToResponse(result); + return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API } return null; } @@ -111,7 +111,7 @@ namespace Ombi.Core.Engine if (result != null) { Logger.LogDebug("Search Result: {result}", result); - return await TransformMovieResultsToResponse(result); + return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API } return null; } @@ -126,7 +126,7 @@ namespace Ombi.Core.Engine if (result != null) { Logger.LogDebug("Search Result: {result}", result); - return await TransformMovieResultsToResponse(result); + return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API } return null; } diff --git a/src/Ombi.Notifications.Templates/Templates/BasicTemplate.html b/src/Ombi.Notifications.Templates/Templates/BasicTemplate.html index ac8a1ddfa..63b86e125 100644 --- a/src/Ombi.Notifications.Templates/Templates/BasicTemplate.html +++ b/src/Ombi.Notifications.Templates/Templates/BasicTemplate.html @@ -149,8 +149,6 @@ -

Hi there!

-

{@SUBJECT}

{@BODY}

diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs index fb6082eab..0b87df7cb 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs @@ -1,6 +1,12 @@ -using System.Linq; +using System; +using System.Linq; using System.Threading.Tasks; +using Hangfire; using Microsoft.EntityFrameworkCore; +using Ombi.Core.Notifications; +using Ombi.Helpers; +using Ombi.Notifications.Models; +using Ombi.Store.Entities; using Ombi.Store.Repository; using Ombi.Store.Repository.Requests; @@ -8,16 +14,19 @@ namespace Ombi.Schedule.Jobs.Plex { public class PlexAvailabilityChecker : IPlexAvailabilityChecker { - public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies) + public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies, + INotificationService notification) { _tvRepo = tvRequest; _repo = repo; _movieRepo = movies; + _notificationService = notification; } private readonly ITvRequestRepository _tvRepo; private readonly IMovieRequestRepository _movieRepo; private readonly IPlexContentRepository _repo; + private readonly INotificationService _notificationService; public async Task Start() { @@ -55,6 +64,13 @@ namespace Ombi.Schedule.Jobs.Plex { // We have fulfulled this request! child.Available = true; + BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions + { + DateTime = DateTime.Now, + NotificationType = NotificationType.RequestAvailable, + RequestId = child.ParentRequestId, + RequestType = RequestType.TvShow + })); } } @@ -76,6 +92,16 @@ namespace Ombi.Schedule.Jobs.Plex } movie.Available = true; + if (movie.Available) + { + BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions + { + DateTime = DateTime.Now, + NotificationType = NotificationType.RequestAvailable, + RequestId = movie.Id, + RequestType = RequestType.Movie + })); + } } await _movieRepo.Save(); diff --git a/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs b/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs index 021d612b8..e263c58e1 100644 --- a/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs +++ b/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs @@ -41,7 +41,7 @@ namespace Ombi.Schedule.Jobs.Radarr if (movies != null) { // Let's remove the old cached data - await _ctx.Database.ExecuteSqlCommandAsync("TRUNCATE TABLE RadarrCache"); + await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM RadarrCache"); var movieIds = new List(); foreach (var m in movies) diff --git a/src/Ombi.Schedule/Ombi.Schedule.csproj b/src/Ombi.Schedule/Ombi.Schedule.csproj index 04e4d7064..192386e0c 100644 --- a/src/Ombi.Schedule/Ombi.Schedule.csproj +++ b/src/Ombi.Schedule/Ombi.Schedule.csproj @@ -22,6 +22,7 @@ + diff --git a/src/Ombi/ClientApp/app/auth/auth.service.ts b/src/Ombi/ClientApp/app/auth/auth.service.ts index b6ec60ab8..e1350715e 100644 --- a/src/Ombi/ClientApp/app/auth/auth.service.ts +++ b/src/Ombi/ClientApp/app/auth/auth.service.ts @@ -34,7 +34,7 @@ export class AuthService extends ServiceHelpers { } var json = this.jwtHelper.decodeToken(token); var roles = json["role"]; - var name = json["name"]; + var name = json["sub"]; var u = { name: name, roles: [] as string[] }; diff --git a/src/Ombi/ClientApp/app/search/moviesearch.component.html b/src/Ombi/ClientApp/app/search/moviesearch.component.html index e9106d264..41d837eec 100644 --- a/src/Ombi/ClientApp/app/search/moviesearch.component.html +++ b/src/Ombi/ClientApp/app/search/moviesearch.component.html @@ -86,7 +86,7 @@
-
+
diff --git a/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.html b/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.html index f4d09a9dc..efdf19ee9 100644 --- a/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.html +++ b/src/Ombi/ClientApp/app/settings/landingpage/landingpage.component.html @@ -25,12 +25,12 @@
-
+ diff --git a/src/Ombi/ClientApp/app/settings/radarr/radarr.component.html b/src/Ombi/ClientApp/app/settings/radarr/radarr.component.html index 93b2b2476..b51f8d46a 100644 --- a/src/Ombi/ClientApp/app/settings/radarr/radarr.component.html +++ b/src/Ombi/ClientApp/app/settings/radarr/radarr.component.html @@ -90,7 +90,7 @@