1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-05 23:53:33 +00:00

Minor refactor

This commit is contained in:
Carlos Gonçalves
2024-05-13 18:03:43 +01:00
parent 4332e7a498
commit 354aec09d9

View File

@@ -135,18 +135,17 @@ namespace Bit.Core.Models.Domain
model.Attachments = new List<AttachmentView>();
var tasks = new List<Task>();
async Task decryptAndAddAttachmentAsync(Attachment attachment, SymmetricCryptoKey decKey)
{
{
var decAttachment = await attachment.DecryptAsync(OrganizationId, model.Key ?? decKey);
model.Attachments.Add(decAttachment);
}
var cryptoService = ServiceContainer.Resolve<ICryptoService>();
foreach (var attachment in Attachments)
{
SymmetricCryptoKey decKey = null;
//If the cipher.key is null but the attachment.cipherKey has a value we will use it to decrypt the attachment
if (Key == null && attachment.CipherKey != null)
{
var cryptoService = ServiceContainer.Resolve<ICryptoService>();
var orgKey = await cryptoService.GetOrgKeyAsync(OrganizationId);
var key = await cryptoService.DecryptToBytesAsync(attachment.CipherKey, orgKey);