diff --git a/libs/common/src/vault/models/domain/attachment.ts b/libs/common/src/vault/models/domain/attachment.ts index 77acbbeb9bb..019eccb5d24 100644 --- a/libs/common/src/vault/models/domain/attachment.ts +++ b/libs/common/src/vault/models/domain/attachment.ts @@ -91,12 +91,18 @@ export class Attachment extends Domain { } } - private async getKeyForDecryption(orgId: string | undefined, userId: UserId): Promise { + private async getKeyForDecryption( + orgId: string | undefined, + userId: UserId, + ): Promise { const keyService = Utils.getContainerService().getKeyService(); - console.log("getKeyForDecryption", orgId, userId); - return orgId != null ? await firstValueFrom(keyService.orgKeys$(userId).pipe( - map((orgKeys) => orgKeys[orgId as OrganizationId] ?? null), - )) : await firstValueFrom(keyService.userKey$(userId)); + return orgId != null + ? await firstValueFrom( + keyService + .orgKeys$(userId) + .pipe(map((orgKeys) => (orgKeys ? (orgKeys[orgId as OrganizationId] ?? null) : null))), + ) + : await firstValueFrom(keyService.userKey$(userId)); } toAttachmentData(): AttachmentData {