mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
Making use of options to initalize update check on first admin registration
This commit is contained in:
39
BTCPayServer/Extensions/ActionLogicExtensions.cs
Normal file
39
BTCPayServer/Extensions/ActionLogicExtensions.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Configuration;
|
||||
using BTCPayServer.Logging;
|
||||
using BTCPayServer.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BTCPayServer
|
||||
{
|
||||
// All logic that would otherwise be duplicated across solution goes into this utility class
|
||||
// ~If~ Once this starts growing out of control, begin extracting action logic classes out of here
|
||||
// Also some of logic in here may be result of parallel development of Greenfield API
|
||||
// It's much better that we extract those common methods then copy paste and maintain same code across codebase
|
||||
internal static class ActionLogicExtensions
|
||||
{
|
||||
internal static async Task FirstAdminRegistered(this SettingsRepository settingsRepository, PoliciesSettings policies,
|
||||
bool updateCheck, bool disableRegistrations)
|
||||
{
|
||||
if (updateCheck)
|
||||
{
|
||||
Logs.PayServer.LogInformation("First admin created, enabling checks for new versions");
|
||||
policies.CheckForNewVersions = updateCheck;
|
||||
}
|
||||
|
||||
if (disableRegistrations)
|
||||
{
|
||||
// Once the admin user has been created lock subsequent user registrations (needs to be disabled for unit tests that require multiple users).
|
||||
Logs.PayServer.LogInformation("First admin created, disabling subscription (disable-registration is set to true)");
|
||||
policies.LockSubscription = true;
|
||||
}
|
||||
|
||||
if (updateCheck || disableRegistrations)
|
||||
await settingsRepository.UpdateSetting(policies);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user