2020-10-21 09:53:05 +02:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
2020-11-17 13:46:23 +01:00
|
|
|
using BTCPayServer.Abstractions.Contracts;
|
2020-10-21 09:53:05 +02:00
|
|
|
using BTCPayServer.Services;
|
2023-11-29 18:51:40 +09:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2020-10-21 09:53:05 +02:00
|
|
|
|
|
|
|
namespace BTCPayServer.Hosting
|
|
|
|
{
|
|
|
|
public class BlockExplorerLinkStartupTask : IStartupTask
|
|
|
|
{
|
|
|
|
private readonly BTCPayNetworkProvider _btcPayNetworkProvider;
|
2023-11-29 18:51:40 +09:00
|
|
|
private readonly TransactionLinkProviders _transactionLinksProviders;
|
|
|
|
private readonly IConfiguration _configuration;
|
2020-10-21 09:53:05 +02:00
|
|
|
|
2023-11-29 18:51:40 +09:00
|
|
|
public BlockExplorerLinkStartupTask(
|
|
|
|
BTCPayNetworkProvider btcPayNetworkProvider,
|
|
|
|
TransactionLinkProviders transactionLinksProviders,
|
|
|
|
IConfiguration configuration)
|
2020-10-21 09:53:05 +02:00
|
|
|
{
|
|
|
|
_btcPayNetworkProvider = btcPayNetworkProvider;
|
2023-11-29 18:51:40 +09:00
|
|
|
_transactionLinksProviders = transactionLinksProviders;
|
|
|
|
_configuration = configuration;
|
2020-10-21 09:53:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public async Task ExecuteAsync(CancellationToken cancellationToken = default)
|
|
|
|
{
|
2023-11-29 18:51:40 +09:00
|
|
|
var blockExplorerLink = _configuration["blockexplorerlink"];
|
|
|
|
if (!string.IsNullOrEmpty(blockExplorerLink))
|
2020-10-21 09:53:05 +02:00
|
|
|
{
|
2023-11-29 18:51:40 +09:00
|
|
|
foreach (var prov in _transactionLinksProviders.Values)
|
|
|
|
prov.OverrideBlockExplorerLink = blockExplorerLink;
|
2020-10-21 09:53:05 +02:00
|
|
|
}
|
2023-11-29 18:51:40 +09:00
|
|
|
await _transactionLinksProviders.RefreshTransactionLinkTemplates();
|
2020-10-21 09:53:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|