From 230fa5ba3bae53d8446afef4b70f8010c2105e46 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 25 Apr 2016 17:03:03 +0100 Subject: [PATCH] Added #27 to albums --- PlexRequests.UI/Content/search.js | 3 +++ PlexRequests.UI/Modules/SearchModule.cs | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/PlexRequests.UI/Content/search.js b/PlexRequests.UI/Content/search.js index 55de573eb..ad1dcf298 100644 --- a/PlexRequests.UI/Content/search.js +++ b/PlexRequests.UI/Content/search.js @@ -142,6 +142,9 @@ $(function () { var type = $form.prop('method'); var url = $form.prop('action'); var data = $form.serialize(); + var $notify = $('#notifyUser').is(':checked'); + + data = data + "¬ify=" + $notify; sendRequestAjax(data, type, url, buttonId); }); diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 07c96bf49..7943f642f 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -99,7 +99,7 @@ namespace PlexRequests.UI.Modules Post["request/movie"] = parameters => RequestMovie((int)Request.Form.movieId, (bool)Request.Form.notify); Post["request/tv"] = parameters => RequestTvShow((int)Request.Form.tvId, (string)Request.Form.seasons, (bool)Request.Form.notify); - Post["request/album"] = parameters => RequestAlbum((string)Request.Form.albumId); + Post["request/album"] = parameters => RequestAlbum((string)Request.Form.albumId, (bool)Request.Form.notify); } private IPlexApi PlexApi { get; } private TheMovieDbApi MovieApi { get; } @@ -706,7 +706,7 @@ namespace PlexRequests.UI.Modules return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" }); } - private Response RequestAlbum(string releaseId) + private Response RequestAlbum(string releaseId, bool notify) { var settings = PrService.GetSettings(); var existingRequest = RequestService.CheckRequest(releaseId); @@ -717,6 +717,10 @@ namespace PlexRequests.UI.Modules Log.Debug("We do have an existing album request"); if (!existingRequest.UserHasRequested(Username)) { + if (notify) + { + existingRequest.AddUserToNotification(Username); + } Log.Debug("Not in the requested list so adding them and updating the request. User: {0}", Username); existingRequest.RequestedUsers.Add(Username); RequestService.UpdateRequest(existingRequest); @@ -774,7 +778,10 @@ namespace PlexRequests.UI.Modules ArtistId = artist.id }; - + if (notify) + { + existingRequest.AddUserToNotification(Username); + } if (ShouldAutoApprove(RequestType.Album, settings)) { Log.Debug("We don't require approval OR the user is in the whitelist");