diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 51a6413fd..5dfe7cf76 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -24,6 +24,10 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // ************************************************************************/ #endregion +using Newtonsoft.Json; +using System; +using System.Collections.Generic; + namespace PlexRequests.Core.SettingModels { public class PlexRequestSettings : Settings @@ -35,5 +39,27 @@ namespace PlexRequests.Core.SettingModels public bool RequireMovieApproval { get; set; } public bool RequireTvShowApproval { get; set; } public int WeeklyRequestLimit { get; set; } + public string NoApprovalUsers { get; set; } + + [JsonIgnore] + public List NoApprovalUserList + { + get + { + var users = new List(); + if (string.IsNullOrEmpty(NoApprovalUsers)) + { + return users; + } + + var splitUsers = NoApprovalUsers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + foreach (var user in splitUsers) + { + if (!string.IsNullOrWhiteSpace(user)) + users.Add(user.Trim()); + } + return users; + } + } } } diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 2a98e8933..49f2d6446 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -220,7 +220,7 @@ namespace PlexRequests.UI.Modules var settings = PrService.GetSettings(); Log.Trace(settings.DumpJson()); - if (!settings.RequireMovieApproval) + if (!settings.RequireMovieApproval || settings.NoApprovalUserList.Any(x => x.Equals(Session[SessionKeys.UsernameKey].ToString(), StringComparison.OrdinalIgnoreCase))) { var cpSettings = CpService.GetSettings(); @@ -247,7 +247,7 @@ namespace PlexRequests.UI.Modules }; NotificationService.Publish(notificationModel); - return Response.AsJson(new JsonResponseModel {Result = true}); + return Response.AsJson(new JsonResponseModel {Result = true, Message = $"{fullMovieName} was successfully added!" }); } return Response.AsJson(new JsonResponseModel @@ -272,7 +272,7 @@ namespace PlexRequests.UI.Modules }; NotificationService.Publish(notificationModel); - return Response.AsJson(new JsonResponseModel { Result = true }); + return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullMovieName} was successfully added!" }); } } @@ -364,7 +364,7 @@ namespace PlexRequests.UI.Modules model.SeasonList = seasonsList.ToArray(); var settings = PrService.GetSettings(); - if (!settings.RequireTvShowApproval) + if (!settings.RequireTvShowApproval || settings.NoApprovalUserList.Any(x => x.Equals(Session[SessionKeys.UsernameKey].ToString(), StringComparison.OrdinalIgnoreCase))) { var sonarrSettings = SonarrService.GetSettings(); var sender = new TvSender(SonarrApi, SickrageApi); diff --git a/PlexRequests.UI/Views/Admin/Settings.cshtml b/PlexRequests.UI/Views/Admin/Settings.cshtml index edbe6009c..078171cda 100644 --- a/PlexRequests.UI/Views/Admin/Settings.cshtml +++ b/PlexRequests.UI/Views/Admin/Settings.cshtml @@ -83,6 +83,15 @@ +

A comma separated list of users whose requests do not require approval.

+
+ +
+ +
+
+
+ @*