This commit is contained in:
Kukks
2024-10-10 11:32:00 +02:00
parent c768d7000b
commit 9b90e10b66
108 changed files with 757 additions and 1350 deletions

View File

@@ -1,11 +1,9 @@
using System.IO;
using System.Threading.Tasks;
using BTCPayServer.Abstractions.Contracts;
using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Abstractions.Models;
using BTCPayServer.Abstractions.Services;
using BTCPayServer.HostedServices.Webhooks;
using BTCPayServer.Services;
using BTCPayServer.Services.Apps;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
@@ -18,12 +16,11 @@ namespace BTCPayServer.Plugins.Subscriptions
{
public override IBTCPayServerPlugin.PluginDependency[] Dependencies { get; } =
[
new() {Identifier = nameof(BTCPayServer), Condition = ">=1.13.0"}
new() {Identifier = nameof(BTCPayServer), Condition = ">=2.0.0"}
];
public override void Execute(IServiceCollection applicationBuilder)
{
applicationBuilder.AddSingleton<ISwaggerProvider, SubscriptionsSwaggerProvider>();
applicationBuilder.AddSingleton<SubscriptionService>();
applicationBuilder.AddSingleton<IWebhookProvider>(o => o.GetRequiredService<SubscriptionService>());
@@ -35,19 +32,17 @@ namespace BTCPayServer.Plugins.Subscriptions
}
}
public class SubscriptionsSwaggerProvider: ISwaggerProvider
public class SubscriptionsSwaggerProvider : ISwaggerProvider
{
private readonly IFileProvider _fileProvider;
public SubscriptionsSwaggerProvider(IWebHostEnvironment webHostEnvironment)
{
_fileProvider = webHostEnvironment.WebRootFileProvider;
}
public async Task<JObject> Fetch()
{
var file = _fileProvider.GetFileInfo("Resources/swagger.subscriptions.json");
using var reader = new StreamReader(file.CreateReadStream());
return JObject.Parse(await reader.ReadToEndAsync());