From cc444811db577cc6f274e383aadf20d603236d9f Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Tue, 19 Feb 2019 13:18:30 +0900 Subject: [PATCH] Rename CrowdfundHubStream to AppHubSteamer --- BTCPayServer.Tests/CrowdfundTests.cs | 2 -- BTCPayServer/Controllers/AppsPublicController.cs | 2 -- BTCPayServer/Hosting/BTCPayServerServices.cs | 4 +--- BTCPayServer/Hosting/Startup.cs | 4 ++-- .../Models/AppViewModels/ViewCrowdfundViewModel.cs | 2 +- .../CrowdfundHub.cs => Services/Apps/AppHub.cs} | 6 +++--- .../Apps/AppHubStreamer.cs} | 13 ++++++------- BTCPayServer/Services/Apps/AppService.cs | 3 +-- BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml | 4 +--- .../AppsPublic/Crowdfund/MinimalCrowdfund.cshtml | 2 +- BTCPayServer/wwwroot/crowdfund/services/listener.js | 2 +- 11 files changed, 17 insertions(+), 27 deletions(-) rename BTCPayServer/{Crowdfund/CrowdfundHub.cs => Services/Apps/AppHub.cs} (94%) rename BTCPayServer/{Crowdfund/CrowdfundHubStreamer.cs => Services/Apps/AppHubStreamer.cs} (90%) diff --git a/BTCPayServer.Tests/CrowdfundTests.cs b/BTCPayServer.Tests/CrowdfundTests.cs index b99ea2248..58ce77ac6 100644 --- a/BTCPayServer.Tests/CrowdfundTests.cs +++ b/BTCPayServer.Tests/CrowdfundTests.cs @@ -5,10 +5,8 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using BTCPayServer.Controllers; -using BTCPayServer.Crowdfund; using BTCPayServer.Data; using BTCPayServer.Events; -using BTCPayServer.Hubs; using BTCPayServer.Models; using BTCPayServer.Models.AppViewModels; using BTCPayServer.Models.StoreViewModels; diff --git a/BTCPayServer/Controllers/AppsPublicController.cs b/BTCPayServer/Controllers/AppsPublicController.cs index 811e04c2a..54709819c 100644 --- a/BTCPayServer/Controllers/AppsPublicController.cs +++ b/BTCPayServer/Controllers/AppsPublicController.cs @@ -6,7 +6,6 @@ using System.IO; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -using BTCPayServer.Crowdfund; using BTCPayServer.Data; using BTCPayServer.Filters; using BTCPayServer.Models; @@ -42,7 +41,6 @@ namespace BTCPayServer.Controllers private AppService _AppService; private InvoiceController _InvoiceController; - private readonly CrowdfundHubStreamer _CrowdfundHubStreamer; private readonly UserManager _UserManager; [HttpGet] diff --git a/BTCPayServer/Hosting/BTCPayServerServices.cs b/BTCPayServer/Hosting/BTCPayServerServices.cs index 9f7ac4373..cb8c1750a 100644 --- a/BTCPayServer/Hosting/BTCPayServerServices.cs +++ b/BTCPayServer/Hosting/BTCPayServerServices.cs @@ -38,8 +38,6 @@ using BTCPayServer.Logging; using BTCPayServer.HostedServices; using Meziantou.AspNetCore.BundleTagHelpers; using System.Security.Claims; -using BTCPayServer.Crowdfund; -using BTCPayServer.Hubs; using BTCPayServer.Payments.Changelly; using BTCPayServer.Payments.Lightning; using BTCPayServer.Security; @@ -185,7 +183,7 @@ namespace BTCPayServer.Hosting services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddTransient, BTCPayClaimsFilter>(); diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index bcddc8ab1..b214c446b 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -34,9 +34,9 @@ using Microsoft.Extensions.Options; using Microsoft.AspNetCore.Mvc.Cors.Internal; using Microsoft.AspNetCore.Server.Kestrel.Core; using System.Net; -using BTCPayServer.Hubs; using Meziantou.AspNetCore.BundleTagHelpers; using BTCPayServer.Security; +using BTCPayServer.Services.Apps; namespace BTCPayServer.Hosting { @@ -164,7 +164,7 @@ namespace BTCPayServer.Hosting app.UseAuthentication(); app.UseSignalR(route => { - route.MapHub("/apps/crowdfund/hub"); + route.MapHub("/apps/hub"); }); app.UseWebSockets(); app.UseStatusCodePages(); diff --git a/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs b/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs index 14a6f4610..19c250b75 100644 --- a/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/ViewCrowdfundViewModel.cs @@ -31,7 +31,7 @@ namespace BTCPayServer.Models.AppViewModels public string DisqusShortname { get; set; } public bool AnimationsEnabled { get; set; } public int ResetEveryAmount { get; set; } - public string ResetEvery { get; set; } + public bool NeverReset { get; set; } public Dictionary PerkCount { get; set; } diff --git a/BTCPayServer/Crowdfund/CrowdfundHub.cs b/BTCPayServer/Services/Apps/AppHub.cs similarity index 94% rename from BTCPayServer/Crowdfund/CrowdfundHub.cs rename to BTCPayServer/Services/Apps/AppHub.cs index a030ed361..bf470be6d 100644 --- a/BTCPayServer/Crowdfund/CrowdfundHub.cs +++ b/BTCPayServer/Services/Apps/AppHub.cs @@ -6,9 +6,9 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.DependencyInjection; -namespace BTCPayServer.Hubs +namespace BTCPayServer.Services.Apps { - public class CrowdfundHub: Hub + public class AppHub: Hub { public const string InvoiceCreated = "InvoiceCreated"; public const string PaymentReceived = "PaymentReceived"; @@ -16,7 +16,7 @@ namespace BTCPayServer.Hubs public const string InvoiceError = "InvoiceError"; private readonly AppsPublicController _AppsPublicController; - public CrowdfundHub(AppsPublicController appsPublicController) + public AppHub(AppsPublicController appsPublicController) { _AppsPublicController = appsPublicController; } diff --git a/BTCPayServer/Crowdfund/CrowdfundHubStreamer.cs b/BTCPayServer/Services/Apps/AppHubStreamer.cs similarity index 90% rename from BTCPayServer/Crowdfund/CrowdfundHubStreamer.cs rename to BTCPayServer/Services/Apps/AppHubStreamer.cs index dc3e9466a..8e35d5841 100644 --- a/BTCPayServer/Crowdfund/CrowdfundHubStreamer.cs +++ b/BTCPayServer/Services/Apps/AppHubStreamer.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using BTCPayServer.Controllers; using BTCPayServer.Data; using BTCPayServer.Events; -using BTCPayServer.Hubs; using BTCPayServer.Logging; using BTCPayServer.Models.AppViewModels; using BTCPayServer.Payments; @@ -22,18 +21,18 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using NBitcoin; -namespace BTCPayServer.Crowdfund +namespace BTCPayServer.Services.Apps { - public class CrowdfundHubStreamer : IHostedService + public class AppHubStreamer : IHostedService { private readonly EventAggregator _EventAggregator; - private readonly IHubContext _HubContext; + private readonly IHubContext _HubContext; private List _Subscriptions; private CancellationTokenSource _Cts; - public CrowdfundHubStreamer(EventAggregator eventAggregator, - IHubContext hubContext) + public AppHubStreamer(EventAggregator eventAggregator, + IHubContext hubContext) { _EventAggregator = eventAggregator; _HubContext = hubContext; @@ -44,7 +43,7 @@ namespace BTCPayServer.Crowdfund if (invoiceEvent.Name == InvoiceEvent.ReceivedPayment) { var data = invoiceEvent.Payment.GetCryptoPaymentData(); - await _HubContext.Clients.Group(appId).SendCoreAsync(CrowdfundHub.PaymentReceived, new object[] + await _HubContext.Clients.Group(appId).SendCoreAsync(AppHub.PaymentReceived, new object[] { data.GetValue(), invoiceEvent.Payment.GetCryptoCode(), diff --git a/BTCPayServer/Services/Apps/AppService.cs b/BTCPayServer/Services/Apps/AppService.cs index f683fe44c..22fce20a8 100644 --- a/BTCPayServer/Services/Apps/AppService.cs +++ b/BTCPayServer/Services/Apps/AppService.cs @@ -6,7 +6,6 @@ using System.IO; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -using BTCPayServer.Crowdfund; using BTCPayServer.Data; using BTCPayServer.Filters; using BTCPayServer.Models; @@ -151,7 +150,7 @@ namespace BTCPayServer.Services.Apps ResetEveryAmount = settings.ResetEveryAmount, DisplayPerksRanking = settings.DisplayPerksRanking, PerkCount = perkCount, - ResetEvery = Enum.GetName(typeof(CrowdfundResetEvery), settings.ResetEvery), + NeverReset = settings.ResetEvery == CrowdfundResetEvery.Never, CurrencyData = _Currencies.GetCurrencyData(settings.TargetCurrency, true), Info = new ViewCrowdfundViewModel.CrowdfundInfo() { diff --git a/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml b/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml index 447d8375e..f641525c6 100644 --- a/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml +++ b/BTCPayServer/Views/Apps/UpdateCrowdfund.cshtml @@ -1,6 +1,4 @@ -@using BTCPayServer.Crowdfund -@using BTCPayServer.Hubs -@addTagHelper *, Meziantou.AspNetCore.BundleTagHelpers +@addTagHelper *, Meziantou.AspNetCore.BundleTagHelpers @model UpdateCrowdfundViewModel @{ ViewData["Title"] = "Update Crowdfund"; diff --git a/BTCPayServer/Views/AppsPublic/Crowdfund/MinimalCrowdfund.cshtml b/BTCPayServer/Views/AppsPublic/Crowdfund/MinimalCrowdfund.cshtml index 90a9ff358..96620d921 100644 --- a/BTCPayServer/Views/AppsPublic/Crowdfund/MinimalCrowdfund.cshtml +++ b/BTCPayServer/Views/AppsPublic/Crowdfund/MinimalCrowdfund.cshtml @@ -37,7 +37,7 @@ { @Model.TargetAmount @Model.TargetCurrency - @if (Model.ResetEveryAmount > 0 && Model.ResetEvery != nameof(CrowdfundResetEvery.Never)) + @if (Model.ResetEveryAmount > 0 && !Model.NeverReset) { Dynamic } diff --git a/BTCPayServer/wwwroot/crowdfund/services/listener.js b/BTCPayServer/wwwroot/crowdfund/services/listener.js index 6323902c7..18871f173 100644 --- a/BTCPayServer/wwwroot/crowdfund/services/listener.js +++ b/BTCPayServer/wwwroot/crowdfund/services/listener.js @@ -1,7 +1,7 @@ var hubListener = function(){ - var connection = new signalR.HubConnectionBuilder().withUrl("/apps/crowdfund/hub").build(); + var connection = new signalR.HubConnectionBuilder().withUrl("/apps/hub").build(); connection.onclose(function(){ eventAggregator.$emit("connection-lost");