From 9e0716d32e874cf8f813858d1eb79f00f2d67fe3 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Wed, 4 Dec 2024 15:27:39 +0100 Subject: [PATCH] Add using to db connections (#221) --- .../AliasVault.SmtpService/Handlers/DatabaseMessageStore.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Services/AliasVault.SmtpService/Handlers/DatabaseMessageStore.cs b/src/Services/AliasVault.SmtpService/Handlers/DatabaseMessageStore.cs index a999f1411..ec420b074 100644 --- a/src/Services/AliasVault.SmtpService/Handlers/DatabaseMessageStore.cs +++ b/src/Services/AliasVault.SmtpService/Handlers/DatabaseMessageStore.cs @@ -298,7 +298,7 @@ public class DatabaseMessageStore(ILogger logger, Config c } // Check if the local part of the toAddress is a known alias (claimed by a user) - var dbContext = await dbContextFactory.CreateDbContextAsync(CancellationToken.None); + await using var dbContext = await dbContextFactory.CreateDbContextAsync(CancellationToken.None); var toAddressLocal = toAddress.User.ToLowerInvariant(); var toAddressDomain = toAddress.Host.ToLowerInvariant(); var userEmailClaim = await dbContext.UserEmailClaims @@ -348,7 +348,7 @@ public class DatabaseMessageStore(ILogger logger, Config c /// The public key of the user to encrypt the mail contents with. private async Task InsertEmailIntoDatabase(MimeMessage message, MailAddress toAddress, UserEncryptionKey userEncryptionKey) { - var dbContext = await dbContextFactory.CreateDbContextAsync(); + await using var dbContext = await dbContextFactory.CreateDbContextAsync(); var newEmail = ConvertMimeMessageToEmail(message, toAddress); newEmail = EmailEncryption.EncryptEmail(newEmail, userEncryptionKey);