Override Block Explorer Links (#2000)

* Override Block Explorer Links

closes #1953

* load overrides after save as well

* fix js
This commit is contained in:
Andrew Camilleri
2020-10-21 09:53:05 +02:00
committed by GitHub
parent 2b19e0fbc6
commit 71894ba245
6 changed files with 134 additions and 15 deletions

View File

@@ -11,6 +11,7 @@ using BTCPayServer.Configuration;
using BTCPayServer.Data;
using BTCPayServer.Events;
using BTCPayServer.HostedServices;
using BTCPayServer.Hosting;
using BTCPayServer.Logging;
using BTCPayServer.Models;
using BTCPayServer.Models.AccountViewModels;
@@ -273,7 +274,7 @@ namespace BTCPayServer.Controllers
[Route("server/policies")]
[HttpPost]
public async Task<IActionResult> Policies(PoliciesSettings settings, string command = "")
public async Task<IActionResult> Policies([FromServices] BTCPayNetworkProvider btcPayNetworkProvider,PoliciesSettings settings, string command = "")
{
ViewBag.UpdateUrlPresent = _Options.UpdateUrl != null;
@@ -292,6 +293,8 @@ namespace BTCPayServer.Controllers
return View(settings);
}
settings.BlockExplorerLinks = settings.BlockExplorerLinks.Where(tuple => btcPayNetworkProvider.GetNetwork(tuple.CryptoCode).BlockExplorerLinkDefault != tuple.Link).ToList();
if (!ModelState.IsValid)
{
return View(settings);
@@ -323,6 +326,7 @@ namespace BTCPayServer.Controllers
}
await _SettingsRepository.UpdateSetting(settings);
BlockExplorerLinkStartupTask.SetLinkOnNetworks(settings.BlockExplorerLinks, btcPayNetworkProvider);
TempData[WellKnownTempData.SuccessMessage] = "Policies updated successfully";
return RedirectToAction(nameof(Policies));
}