mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Do not cleanup unreachable stores (#5025)
This commit is contained in:
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Amazon.S3.Transfer;
|
|
||||||
using BTCPayServer.Abstractions.Constants;
|
using BTCPayServer.Abstractions.Constants;
|
||||||
using BTCPayServer.Abstractions.Extensions;
|
using BTCPayServer.Abstractions.Extensions;
|
||||||
using BTCPayServer.Abstractions.Models;
|
using BTCPayServer.Abstractions.Models;
|
||||||
@@ -167,9 +166,17 @@ namespace BTCPayServer.Controllers
|
|||||||
[FromServices] StoreRepository storeRepository,
|
[FromServices] StoreRepository storeRepository,
|
||||||
string role)
|
string role)
|
||||||
{
|
{
|
||||||
await storeRepository.SetDefaultRole(role);
|
var resolved = await storeRepository.ResolveStoreRoleId(null, role);
|
||||||
|
if (resolved is null)
|
||||||
TempData[WellKnownTempData.SuccessMessage] = "Role set default";
|
{
|
||||||
|
TempData[WellKnownTempData.ErrorMessage] = "Role could not be set as default";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
await storeRepository.SetDefaultRole(role);
|
||||||
|
TempData[WellKnownTempData.SuccessMessage] = "Role set default";
|
||||||
|
}
|
||||||
|
|
||||||
return RedirectToAction(nameof(ListRoles));
|
return RedirectToAction(nameof(ListRoles));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,12 +111,6 @@ namespace BTCPayServer.Hosting
|
|||||||
settings.DeprecatedLightningConnectionStringCheck = true;
|
settings.DeprecatedLightningConnectionStringCheck = true;
|
||||||
await _Settings.UpdateSetting(settings);
|
await _Settings.UpdateSetting(settings);
|
||||||
}
|
}
|
||||||
if (!settings.UnreachableStoreCheck)
|
|
||||||
{
|
|
||||||
await UnreachableStoreCheck();
|
|
||||||
settings.UnreachableStoreCheck = true;
|
|
||||||
await _Settings.UpdateSetting(settings);
|
|
||||||
}
|
|
||||||
if (!settings.ConvertMultiplierToSpread)
|
if (!settings.ConvertMultiplierToSpread)
|
||||||
{
|
{
|
||||||
await ConvertMultiplierToSpread();
|
await ConvertMultiplierToSpread();
|
||||||
@@ -1068,11 +1062,6 @@ retry:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task UnreachableStoreCheck()
|
|
||||||
{
|
|
||||||
return _StoreRepository.CleanUnreachableStores();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task DeprecatedLightningConnectionStringCheck()
|
private async Task DeprecatedLightningConnectionStringCheck()
|
||||||
{
|
{
|
||||||
using var ctx = _DBContextFactory.CreateContext();
|
using var ctx = _DBContextFactory.CreateContext();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace BTCPayServer.Services
|
|||||||
[JsonProperty("MigrateHotwalletProperty2")]
|
[JsonProperty("MigrateHotwalletProperty2")]
|
||||||
public bool MigrateHotwalletProperty { get; set; }
|
public bool MigrateHotwalletProperty { get; set; }
|
||||||
public bool MigrateU2FToFIDO2 { get; set; }
|
public bool MigrateU2FToFIDO2 { get; set; }
|
||||||
public bool UnreachableStoreCheck { get; set; }
|
|
||||||
public bool DeprecatedLightningConnectionStringCheck { get; set; }
|
public bool DeprecatedLightningConnectionStringCheck { get; set; }
|
||||||
public bool ConvertMultiplierToSpread { get; set; }
|
public bool ConvertMultiplierToSpread { get; set; }
|
||||||
public bool ConvertNetworkFeeProperty { get; set; }
|
public bool ConvertNetworkFeeProperty { get; set; }
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Amazon.S3;
|
||||||
using BTCPayServer.Abstractions.Contracts;
|
using BTCPayServer.Abstractions.Contracts;
|
||||||
using BTCPayServer.Client;
|
using BTCPayServer.Client;
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
@@ -229,18 +230,19 @@ namespace BTCPayServer.Services.Stores
|
|||||||
/// <param name="storeId"></param>
|
/// <param name="storeId"></param>
|
||||||
/// <param name="role"></param>
|
/// <param name="role"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<StoreRoleId?> ResolveStoreRoleId(string storeId, string? role)
|
public async Task<StoreRoleId?> ResolveStoreRoleId(string? storeId, string? role)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(role))
|
if (string.IsNullOrWhiteSpace(role))
|
||||||
return null;
|
return null;
|
||||||
var isStoreRole = role.Contains("::", StringComparison.OrdinalIgnoreCase);
|
if (storeId?.Contains("::", StringComparison.OrdinalIgnoreCase) is true)
|
||||||
if(isStoreRole && (string.IsNullOrEmpty(storeId) || !role.Contains(storeId, StringComparison.InvariantCultureIgnoreCase)))
|
|
||||||
return null;
|
return null;
|
||||||
var roleId = StoreRoleId.Parse(role);
|
var roleId = StoreRoleId.Parse(role);
|
||||||
if (roleId.StoreId != null && roleId.StoreId != storeId)
|
if (roleId.StoreId != null && roleId.StoreId != storeId)
|
||||||
return null;
|
return null;
|
||||||
if ((await GetStoreRole(roleId)) != null)
|
if ((await GetStoreRole(roleId)) != null)
|
||||||
return roleId;
|
return roleId;
|
||||||
|
if (string.IsNullOrEmpty(storeId))
|
||||||
|
return null;
|
||||||
if (roleId.IsServerRole)
|
if (roleId.IsServerRole)
|
||||||
roleId = new StoreRoleId(storeId, role);
|
roleId = new StoreRoleId(storeId, role);
|
||||||
if ((await GetStoreRole(roleId)) != null)
|
if ((await GetStoreRole(roleId)) != null)
|
||||||
|
|||||||
@@ -157,8 +157,6 @@ namespace BTCPayServer.Services
|
|||||||
{
|
{
|
||||||
_logger.LogError($"Failed to delete user {user.Id}");
|
_logger.LogError($"Failed to delete user {user.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
await _storeRepository.CleanUnreachableStores();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user