User synchronization revamped.

This commit is contained in:
2025-07-04 23:33:33 +02:00
parent 4393977389
commit c775e3a25e
14 changed files with 348 additions and 139 deletions

View File

@ -53,16 +53,22 @@ namespace MessengerApi.Configuration.Model
/// </summary>
public HousekeepingMessageStates HousekeepingMessageState { get; set; }
/// <summary>
/// File containing all user credentials.
/// </summary>
public FileInfo UsersConfig { get; set; }
public MessengerConfiguration() { }
public MessengerConfiguration(string[] origins, PersistenceConfiguration persistenceConfiguration)
{
if(persistenceConfiguration == null)
if (persistenceConfiguration == null)
{
throw new ArgumentNullException(nameof(persistenceConfiguration));
}
this.PersistenceConfiguration = persistenceConfiguration;
this.UsersConfig = new FileInfo("./users.conf");
this.Origins = origins ?? [];
this.Proxies = [];
this.RateLimitPerMinute = 120;
@ -84,6 +90,7 @@ namespace MessengerApi.Configuration.Model
Populate<int>(config, Env.HOUSEKEEPING_MESSAGE_AGE_IN_MINUTES, x => this.HousekeepingMessageAgeInMinutes = x);
Populate<string>(config, Env.HOUSEKEEPING_MESSAGE_STATE, x => this.HousekeepingMessageState = HousekeepingMessageStateParser.Parse(x));
Populate<string>(config, Env.LOGGING_VERBOSITY, x => this.Verbosity = LoggingVerbosityParser.Parse(x));
Populate<string>(config, Env.USERSCONFIG_FILE_PATH, x => this.UsersConfig = new FileInfo(x));
void Populate<T>(IEnvironmentConfigurationSource config, string key, Action<T> set)
{

View File

@ -15,6 +15,7 @@
public const string HOUSEKEEPING_MESSAGE_AGE_IN_MINUTES = nameof(HOUSEKEEPING_MESSAGE_AGE_IN_MINUTES);
public const string HOUSEKEEPING_MESSAGE_STATE = nameof(HOUSEKEEPING_MESSAGE_STATE);
public const string LOGGING_VERBOSITY = nameof(LOGGING_VERBOSITY);
public const string USERSCONFIG_FILE_PATH = nameof(USERSCONFIG_FILE_PATH);
}
}
}