mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 15:56:05 -07:00
Added Paypalme options, no UI yet (#568)
* Added Paypalme options * Added Custom Donation UI * Updated error checking * Review fixes to donation work
This commit is contained in:
parent
6a7ea83f99
commit
41e6d72210
7 changed files with 123 additions and 2 deletions
52
PlexRequests.UI/Modules/DonationLinkModule.cs
Normal file
52
PlexRequests.UI/Modules/DonationLinkModule.cs
Normal file
|
@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue