Skip to content

Commit ef98345

Browse files
author
Thomas Belin
authored
runfix(core): Use core to decrypt federated messages (#12082)
1 parent 36182b2 commit ef98345

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/script/conversation/MessageRepository.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,6 @@ export class MessageRepository {
893893
try {
894894
// We delete the stored session so that it can be recreated later on
895895
const session_id = await this.cryptography_repository.deleteSession(userId, client_id);
896-
this.core.service!.cryptography.cryptobox.session_delete(session_id);
897896
if (session_id) {
898897
this.logger.info(`Deleted session with client '${client_id}' of user '${userId.id}'.`);
899898
} else {

src/script/cryptography/CryptographyRepository.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ export class CryptographyRepository {
231231

232232
deleteSession(userId: QualifiedId, clientId: string): Promise<string> {
233233
const sessionId = constructClientPrimaryKey(userId, clientId);
234+
this.core.service!.cryptography.cryptobox.session_delete(sessionId);
234235
return this.cryptobox.session_delete(sessionId);
235236
}
236237

@@ -460,7 +461,9 @@ export class CryptographyRepository {
460461
const cipherText = cipherTextArray.buffer;
461462
const sessionId = constructClientPrimaryKey(userId, eventData.sender);
462463

463-
const plaintext = await this.cryptobox.decrypt(sessionId, cipherText);
464+
const plaintext = isFederatedEnv
465+
? await this.core.service.cryptography.cryptobox.decrypt(sessionId, cipherText)
466+
: await this.cryptobox.decrypt(sessionId, cipherText);
464467
return GenericMessage.decode(plaintext);
465468
}
466469

0 commit comments

Comments
 (0)