MainWindow: Delay email sending
Test / Run tests (push) Successful in 2m4s

This commit is contained in:
2026-08-11 18:25:16 +02:00
parent 07b197958d
commit 76ea3513ac
4 changed files with 7 additions and 3 deletions
+4 -2
View File
@@ -57,9 +57,10 @@ namespace Elwig.Helpers {
public string? SmtpUsername = null;
public string? SmtpPassword = null;
public string? SmtpFrom = null;
public (string Host, int Port, string Mode, string Username, string Password, string From)? Smtp =>
public double SmtpWait = 0;
public (string Host, int Port, string Mode, string Username, string Password, string From, double Wait)? Smtp =>
SmtpHost == null || SmtpPort == null || SmtpMode == null || SmtpUsername == null || SmtpPassword == null || SmtpFrom == null ?
null : (SmtpHost, (int)SmtpPort, SmtpMode, SmtpUsername, SmtpPassword, SmtpFrom);
null : (SmtpHost, (int)SmtpPort, SmtpMode, SmtpUsername, SmtpPassword, SmtpFrom, SmtpWait);
public IList<ScaleConfig> Scales;
private readonly List<ScaleConfig> ScaleList = [];
@@ -92,6 +93,7 @@ namespace Elwig.Helpers {
SmtpUsername = config["smtp:username"];
SmtpPassword = config["smtp:password"];
SmtpFrom = config["smtp:from"];
SmtpWait = double.TryParse(config["smtp:wait"], out var res) ? res : 0;
var scales = config.AsEnumerable().Where(i => i.Key.StartsWith("scale.")).GroupBy(i => i.Key.Split(':')[0][6..]).Select(i => i.Key).Order();
ScaleList.Clear();
+1 -1
View File
@@ -516,7 +516,7 @@ namespace Elwig.Helpers {
public static async Task<SmtpClient?> GetSmtpClient() {
if (App.Config.Smtp == null)
return null;
var (host, port, mode, username, password, _) = App.Config.Smtp.Value;
var (host, port, mode, username, password, _, _) = App.Config.Smtp.Value;
var client = new SmtpClient();
await client.ConnectAsync(host, port, mode == "starttls" ? SecureSocketOptions.StartTls : SecureSocketOptions.None);
await client.AuthenticateAsync(username, password);
+1
View File
@@ -958,6 +958,7 @@ namespace Elwig.Windows {
m.EmailAddresses.OrderBy(a => a.Nr).Select(a => a.Address).ToArray(),
subject, docs.Select(d => d.Title).ToArray()
)]);
await Task.Delay((int)(App.Config.SmtpWait * 1000));
}
});
+1
View File
@@ -26,6 +26,7 @@ auto = true
;username = ""
;password = ""
;from = mail@wg.at
;wait = 0.5
;[scale.1]
;type = SysTec-IT