From 7d1a8d290b8772d92e8c94aead86e3ccca42369f Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 17 May 2023 22:55:44 +0100 Subject: [PATCH] Fix bug with pendingEventOrdering: "chronological" If we don't do this, then we end up trying to match the MAC on our own `m.key.verification.mac`, which of course fails. --- src/crypto/verification/request/InRoomChannel.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/crypto/verification/request/InRoomChannel.ts b/src/crypto/verification/request/InRoomChannel.ts index ff11bf192bb..ae8ced5ffe2 100644 --- a/src/crypto/verification/request/InRoomChannel.ts +++ b/src/crypto/verification/request/InRoomChannel.ts @@ -208,10 +208,17 @@ export class InRoomChannel implements IVerificationChannel { this.requestEventId = InRoomChannel.getTransactionId(event); } + // With pendingEventOrdering: "chronological", we will see events that have been sent but not yet reflected + // back via /sync. These are "local echoes" and are identifiable by their txnId + const isLocalEcho = !!event.getTxnId(); + + // Alternatively, we may see an event that we sent that is reflected back via /sync. These are "remote echoes" + // and have a transaction ID in the "unsigned" data const isRemoteEcho = !!event.getUnsigned().transaction_id; + const isSentByUs = event.getSender() === this.client.getUserId(); - return request.handleEvent(type, event, isLiveEvent, isRemoteEcho, isSentByUs); + return request.handleEvent(type, event, isLiveEvent, isLocalEcho || isRemoteEcho, isSentByUs); } /**