-
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #579 from tidusjar/dev
Dev to master
- Loading branch information
Showing
10 changed files
with
149 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<PlexRequestSettings> 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<Response> GetCustomDonationUrl(ISettingsService<PlexRequestSettings> 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 }); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters