diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs
index 078798b3e..65afd1559 100644
--- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs
+++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs
@@ -60,6 +60,9 @@ namespace PlexRequests.Core.SettingModels
public bool DisableTvRequestsBySeason { get; set; }
public bool SendRecentlyAddedEmail { get; set; }
+ public string CustomDonationUrl { get; set; }
+ public bool EnableCustomDonationUrl { get; set; }
+ public string CustomDonationMessage { get; set; }
///
/// The CSS name of the theme we want
///
diff --git a/PlexRequests.Services/Jobs/RecentlyAdded.cs b/PlexRequests.Services/Jobs/RecentlyAdded.cs
index 8e12f76c9..c138b942b 100644
--- a/PlexRequests.Services/Jobs/RecentlyAdded.cs
+++ b/PlexRequests.Services/Jobs/RecentlyAdded.cs
@@ -48,13 +48,14 @@ namespace PlexRequests.Services.Jobs
public class RecentlyAdded : IJob, IRecentlyAdded
{
public RecentlyAdded(IPlexApi api, ISettingsService plexSettings, ISettingsService email,
- ISettingsService scheduledService, IJobRecord rec)
+ ISettingsService scheduledService, IJobRecord rec, ISettingsService plexRequest)
{
JobRecord = rec;
Api = api;
PlexSettings = plexSettings;
EmailSettings = email;
ScheduledJobsSettings = scheduledService;
+ PlexRequestSettings = plexRequest;
}
private IPlexApi Api { get; }
@@ -62,6 +63,7 @@ namespace PlexRequests.Services.Jobs
private readonly TheMovieDbApi _movieApi = new TheMovieDbApi();
private ISettingsService PlexSettings { get; }
private ISettingsService EmailSettings { get; }
+ private ISettingsService PlexRequestSettings { get; }
private ISettingsService ScheduledJobsSettings { get; }
private IJobRecord JobRecord { get; }
@@ -71,14 +73,19 @@ namespace PlexRequests.Services.Jobs
{
try
{
+ var settings = PlexRequestSettings.GetSettings();
+ if (!settings.SendRecentlyAddedEmail)
+ {
+ return;
+ }
var jobs = JobRecord.GetJobs();
var thisJob =
jobs.FirstOrDefault(
x => x.Name.Equals(JobNames.RecentlyAddedEmail, StringComparison.CurrentCultureIgnoreCase));
- var settings = ScheduledJobsSettings.GetSettings();
+ var jobSettings = ScheduledJobsSettings.GetSettings();
- if (thisJob?.LastRun > DateTime.Now.AddHours(-settings.RecentlyAdded))
+ if (thisJob?.LastRun > DateTime.Now.AddHours(-jobSettings.RecentlyAdded))
{
return;
}
@@ -147,14 +154,19 @@ namespace PlexRequests.Services.Jobs
sb.AppendFormat("{1} {2}
",
info.ImdbId, info.Title, info.ReleaseDate?.ToString("yyyy") ?? string.Empty);
- sb.AppendFormat("Genre: {0}
", string.Join(", ", info.Genres.Select(x => x.Name.ToString()).ToArray()));
+ if (info.Genres.Any())
+ {
+ sb.AppendFormat(
+ "Genre: {0}
",
+ string.Join(", ", info.Genres.Select(x => x.Name.ToString()).ToArray()));
+ }
sb.AppendFormat("{0}
", info.Overview);
sb.Append("");
sb.Append(" ");
sb.Append(" ");
sb.Append(" ");
+ sb.Append("");
}
sb.Append("
");
@@ -192,10 +204,10 @@ namespace PlexRequests.Services.Jobs
string.IsNullOrEmpty(parentMetaData.Directory.Summary) ? info.summary : parentMetaData.Directory.Summary); // Episode Summary
sb.Append(" | ");
sb.Append(" ");
sb.Append(" ");
sb.Append(" ");
+ sb.Append("");
}
sb.Append("
");
}
diff --git a/PlexRequests.UI/Modules/BaseAuthModule.cs b/PlexRequests.UI/Modules/BaseAuthModule.cs
index d3d3de5d9..e1a3a26de 100644
--- a/PlexRequests.UI/Modules/BaseAuthModule.cs
+++ b/PlexRequests.UI/Modules/BaseAuthModule.cs
@@ -64,9 +64,12 @@ namespace PlexRequests.UI.Modules
var redirectPath = string.IsNullOrEmpty(baseUrl) ? "~/userlogin" : $"~/{baseUrl}/userlogin";
- return Session[SessionKeys.UsernameKey] == null
- ? Context.GetRedirect(redirectPath)
- : null;
+ if (Session[SessionKeys.UsernameKey] == null && Context?.CurrentUser == null)
+ {
+ return Context.GetRedirect(redirectPath);
+ }
+
+ return null;
}
}
}
diff --git a/PlexRequests.UI/Modules/DonationLinkModule.cs b/PlexRequests.UI/Modules/DonationLinkModule.cs
new file mode 100644
index 000000000..9ede62e41
--- /dev/null
+++ b/PlexRequests.UI/Modules/DonationLinkModule.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Threading.Tasks;
+
+using Nancy;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using NLog;
+
+using PlexRequests.Core;
+using PlexRequests.Core.SettingModels;
+using PlexRequests.Helpers;
+using PlexRequests.UI.Models;
+
+namespace PlexRequests.UI.Modules
+{
+ public class DonationLinkModule : BaseAuthModule
+ {
+ public DonationLinkModule(ICacheProvider provider, ISettingsService pr) : base("customDonation", pr)
+ {
+ Cache = provider;
+
+ Get["/", true] = async (x, ct) => await GetCustomDonationUrl(pr);
+ }
+
+ private ICacheProvider Cache { get; }
+
+ private static Logger Log = LogManager.GetCurrentClassLogger();
+
+ private async Task GetCustomDonationUrl(ISettingsService pr)
+ {
+ PlexRequestSettings settings = await pr.GetSettingsAsync();
+ try
+ {
+ if (settings.EnableCustomDonationUrl)
+ {
+ return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage });
+ }
+ else
+ {
+ return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage });
+ }
+ }
+ catch (Exception e)
+ {
+ Log.Warn("Exception Thrown when attempting to check the custom donation url");
+ Log.Warn(e);
+ return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage });
+ }
+ }
+ }
+
+}
diff --git a/PlexRequests.UI/Modules/UserLoginModule.cs b/PlexRequests.UI/Modules/UserLoginModule.cs
index 713f43987..d9a0c5327 100644
--- a/PlexRequests.UI/Modules/UserLoginModule.cs
+++ b/PlexRequests.UI/Modules/UserLoginModule.cs
@@ -65,8 +65,8 @@ namespace PlexRequests.UI.Modules
{
if (!string.IsNullOrEmpty(Username) || IsAdmin)
{
- var uri = Linker.BuildRelativeUri(Context, "SearchIndex");
- return Response.AsRedirect(uri.ToString());
+ var url = Linker.BuildRelativeUri(Context, "SearchIndex").ToString();
+ return Response.AsRedirect(url);
}
var settings = await AuthService.GetSettingsAsync();
return View["Index", settings];
diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj
index 1df11b208..bd88121f2 100644
--- a/PlexRequests.UI/PlexRequests.UI.csproj
+++ b/PlexRequests.UI/PlexRequests.UI.csproj
@@ -248,6 +248,7 @@
+
diff --git a/PlexRequests.UI/Resources/UI.resx b/PlexRequests.UI/Resources/UI.resx
index 4f23fce97..883e20be1 100644
--- a/PlexRequests.UI/Resources/UI.resx
+++ b/PlexRequests.UI/Resources/UI.resx
@@ -443,4 +443,7 @@
View In Plex
+
+ Donate to Library Maintainer
+
\ No newline at end of file
diff --git a/PlexRequests.UI/Resources/UI1.Designer.cs b/PlexRequests.UI/Resources/UI1.Designer.cs
index 6cd282c32..acb53c9bb 100644
--- a/PlexRequests.UI/Resources/UI1.Designer.cs
+++ b/PlexRequests.UI/Resources/UI1.Designer.cs
@@ -114,6 +114,15 @@ namespace PlexRequests.UI.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Donate to Library Maintainer.
+ ///
+ public static string Custom_Donation_Default {
+ get {
+ return ResourceManager.GetString("Custom_Donation_Default", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Issue.
///
diff --git a/PlexRequests.UI/Views/Admin/Settings.cshtml b/PlexRequests.UI/Views/Admin/Settings.cshtml
index 386b209c8..8ed022ee8 100644
--- a/PlexRequests.UI/Views/Admin/Settings.cshtml
+++ b/PlexRequests.UI/Views/Admin/Settings.cshtml
@@ -273,10 +273,38 @@
}
+
+
+
+
+
- A comma separated list of users whose requests do not require approval (These users also do not have a request limit).
+ A comma separated list of users whose requests do not require approval (These users also do not have a request limit).
+
\ No newline at end of file
|