diff --git a/BTCPayServer/Controllers/AppsPublicController.cs b/BTCPayServer/Controllers/AppsPublicController.cs index 26ac4d99b..b0cc981da 100644 --- a/BTCPayServer/Controllers/AppsPublicController.cs +++ b/BTCPayServer/Controllers/AppsPublicController.cs @@ -90,12 +90,16 @@ namespace BTCPayServer.Controllers public async Task ViewCrowdfund(string appId, string statusMessage) { - var app = await _AppsHelper.GetApp(appId, AppType.Crowdfund, true); - if (app == null || - (!app.GetSettings().Enabled && - _AppsHelper.GetAppDataIfOwner(GetUserId(), appId, AppType.Crowdfund) == null)) - return NotFound(); + var app = await _AppsHelper.GetApp(appId, AppType.Crowdfund, true); + if (app == null) + return NotFound(); + var settings = app.GetSettings(); + if (settings.Enabled) return View(await _CrowdfundHubStreamer.GetCrowdfundInfo(appId)); + var isAdmin = await _AppsHelper.GetAppDataIfOwner(GetUserId(), appId, AppType.Crowdfund) != null; + if(!isAdmin) + return NotFound(); + return View(await _CrowdfundHubStreamer.GetCrowdfundInfo(appId)); } @@ -114,9 +118,9 @@ namespace BTCPayServer.Controllers var isAdmin = false; if (!settings.Enabled) { - isAdmin = await _AppsHelper.GetAppDataIfOwner(GetUserId(), appId, AppType.Crowdfund) == null; + isAdmin = await _AppsHelper.GetAppDataIfOwner(GetUserId(), appId, AppType.Crowdfund) != null; if(!isAdmin) - return NotFound(); + return NotFound("Crowdfund is not currently active"); } var info = await _CrowdfundHubStreamer.GetCrowdfundInfo(appId); @@ -129,7 +133,7 @@ namespace BTCPayServer.Controllers (info.Info.PendingProgressPercentage.GetValueOrDefault(0) + info.Info.ProgressPercentage.GetValueOrDefault(0)) >= 100))) { - return NotFound(); + return NotFound("Crowdfund is not currently active"); } var store = await _AppsHelper.GetStore(app); @@ -150,7 +154,7 @@ namespace BTCPayServer.Controllers if (settings.EnforceTargetAmount && info.TargetAmount.HasValue && price > (info.TargetAmount - (info.Info.CurrentAmount + info.Info.CurrentPendingAmount))) { - return NotFound(); + return NotFound("Contribution Amount is more than is currently allowed."); } store.AdditionalClaims.Add(new Claim(Policies.CanCreateInvoice.Key, store.Id)); diff --git a/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml b/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml index 89a2d1eb0..7450b5482 100644 --- a/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml +++ b/BTCPayServer/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml @@ -93,14 +93,14 @@ - +
  • {{stat.label}} {{stat.value}}
- + Goal resets every {{srvModel.resetEveryAmount}} {{srvModel.resetEvery}} {{srvModel.resetEveryAmount>1?'s': ''}} diff --git a/BTCPayServer/wwwroot/crowdfund/app.js b/BTCPayServer/wwwroot/crowdfund/app.js index 162d39e0e..2dda8241c 100644 --- a/BTCPayServer/wwwroot/crowdfund/app.js +++ b/BTCPayServer/wwwroot/crowdfund/app.js @@ -182,6 +182,26 @@ addLoadEvent(function (ev) { self.contributeModalOpen = false; }); + eventAggregator.$on("invoice-error", function(error){ + var msg = ""; + if(typeof error === "string"){ + msg = error; + }else if(!error){ + msg = "Unknown Error"; + }else{ + msg = JSON.stringify(error); + } + + Vue.toasted.show("Error creating invoice: " + msg, { + iconPack: "fontawesome", + icon: "exclamation-triangle", + fullWidth: false, + theme: "bubble", + type: "error", + position: "top-center", + duration: 10000 + } ); + }); eventAggregator.$on("payment-received", function (amount, cryptoCode, type) { var onChain = type.toLowerCase() === "btclike"; if(self.sound) { diff --git a/BTCPayServer/wwwroot/crowdfund/services/listener.js b/BTCPayServer/wwwroot/crowdfund/services/listener.js index d0a54e612..6323902c7 100644 --- a/BTCPayServer/wwwroot/crowdfund/services/listener.js +++ b/BTCPayServer/wwwroot/crowdfund/services/listener.js @@ -14,6 +14,9 @@ var hubListener = function(){ connection.on("InvoiceCreated", function(invoiceId){ eventAggregator.$emit("invoice-created", invoiceId); }); + connection.on("InvoiceError", function(error){ + eventAggregator.$emit("invoice-error", error); + }); connection.on("InfoUpdated", function(model){ eventAggregator.$emit("info-updated", model); });