#132 auto-approve for admins

pull/140/head
Drewster727 9 years ago
parent 2d4f680537
commit ea6f33102a

@ -31,6 +31,7 @@ using System.Linq;
using Nancy; using Nancy;
using Nancy.Responses.Negotiation; using Nancy.Responses.Negotiation;
using Nancy.Security;
using NLog; using NLog;
@ -107,6 +108,13 @@ namespace PlexRequests.UI.Modules
private IHeadphonesApi HeadphonesApi { get; } private IHeadphonesApi HeadphonesApi { get; }
private static Logger Log = LogManager.GetCurrentClassLogger(); private static Logger Log = LogManager.GetCurrentClassLogger();
private bool IsAdmin {
get
{
return Context.CurrentUser.IsAuthenticated();
}
}
private Negotiator RequestLoad() private Negotiator RequestLoad()
{ {
var settings = PrService.GetSettings(); var settings = PrService.GetSettings();
@ -260,7 +268,7 @@ namespace PlexRequests.UI.Modules
}; };
Log.Trace(settings.DumpJson()); Log.Trace(settings.DumpJson());
if (!settings.RequireMovieApproval || settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase))) if (IsAdmin || !settings.RequireMovieApproval || settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase)))
{ {
var cpSettings = CpService.GetSettings(); var cpSettings = CpService.GetSettings();
@ -414,7 +422,7 @@ namespace PlexRequests.UI.Modules
model.SeasonList = seasonsList.ToArray(); model.SeasonList = seasonsList.ToArray();
if (!settings.RequireTvShowApproval || settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase))) if (IsAdmin || !settings.RequireTvShowApproval || settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase)))
{ {
var sonarrSettings = SonarrService.GetSettings(); var sonarrSettings = SonarrService.GetSettings();
var sender = new TvSender(SonarrApi, SickrageApi); var sender = new TvSender(SonarrApi, SickrageApi);
@ -529,7 +537,7 @@ namespace PlexRequests.UI.Modules
}; };
if (!settings.RequireMusicApproval || if (IsAdmin || !settings.RequireMusicApproval ||
settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase))) settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase)))
{ {
Log.Debug("We don't require approval OR the user is in the whitelist"); Log.Debug("We don't require approval OR the user is in the whitelist");

Loading…
Cancel
Save