diff options
author | vnugent <public@vaughnnugent.com> | 2023-06-22 21:13:35 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-06-22 21:13:35 -0400 |
commit | ce3b1dc1e88db23cfb99e135f7d57a08194560c7 (patch) | |
tree | f3b5c8db42c6800431e296487cb5b689aca5bc0d /lib/Emails.Transactional.Plugin/src/Api Endpoints | |
parent | b8499ea2f5e31dba0da10692cd1fd1bba83073bb (diff) |
Extensions async updates
Diffstat (limited to 'lib/Emails.Transactional.Plugin/src/Api Endpoints')
-rw-r--r-- | lib/Emails.Transactional.Plugin/src/Api Endpoints/SendEndpoint.cs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Emails.Transactional.Plugin/src/Api Endpoints/SendEndpoint.cs b/lib/Emails.Transactional.Plugin/src/Api Endpoints/SendEndpoint.cs index e5ca88b..16c0d9a 100644 --- a/lib/Emails.Transactional.Plugin/src/Api Endpoints/SendEndpoint.cs +++ b/lib/Emails.Transactional.Plugin/src/Api Endpoints/SendEndpoint.cs @@ -112,9 +112,12 @@ namespace Emails.Transactional.Endpoints //Load SMTP _ = plugin.ObserveWork(async () => { - using SecretResult? password = await plugin.TryGetSecretAsync("smtp_password") ?? throw new KeyNotFoundException("Missing required 'smtp_password' in secrets"); + //Get the password from the secret store + string password = await plugin.GetSecretAsync("smtp_password").ToLazy(static r => r.Result.ToString()); + //Copy the secre to the network credential - NetworkCredential cred = new(username, password.Result.ToString()); + NetworkCredential cred = new(username, password); + //Init email service EmailService = new(serverUri, cred, timeout); }); @@ -130,13 +133,11 @@ namespace Emails.Transactional.Endpoints //Load the client when the secret finishes loading _ = plugin.ObserveWork(async () => { - using SecretResult? secret = await plugin.TryGetSecretAsync("s3_secret") ?? throw new KeyNotFoundException("Missing required s3 client secret in config"); - + string s3Secret = await plugin.GetSecretAsync("s3_secret").ToLazy(static r => r.Result.ToString()); Client.WithEndpoint(S3Config.ServerAddress) - .WithCredentials(S3Config.ClientId, secret.Result.ToString()); - - Client.WithSSL(S3Config.UseSsl.HasValue && S3Config.UseSsl.Value); + .WithCredentials(S3Config.ClientId, s3Secret) + .WithSSL(S3Config.UseSsl.HasValue && S3Config.UseSsl.Value); //Accept optional region if (!string.IsNullOrWhiteSpace(S3Config.Region)) |