@@ -324,6 +324,12 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
324
324
*/
325
325
public verificationRequest ?: VerificationRequest ;
326
326
327
+ /*
328
+ * True if this event is an encrypted event which we failed to decrypt, the receiver's device is unverified and
329
+ * the sender has disabled encrypting to unverified devices.
330
+ */
331
+ public isEncryptedDisabledForUnverifiedDevices = false ;
332
+
327
333
private readonly reEmitter : TypedReEmitter < MatrixEventEmittedEvents , MatrixEventHandlerMap > ;
328
334
329
335
/**
@@ -704,22 +710,6 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
704
710
return this . clearEvent ?. content ?. msgtype === "m.bad.encrypted" ;
705
711
}
706
712
707
- /**
708
- * Check if this event is an encrypted event which we failed to decrypt, the receiver's device is unverified and
709
- * the sender has disabled encrypting to unverified devices.
710
- *
711
- * (This implies that we might retry decryption at some point in the future)
712
- *
713
- * @returns boolean
714
- */
715
- public isEncryptedDisabledForUnverifiedDevices ( ) : boolean {
716
- return (
717
- this . isDecryptionFailure ( ) &&
718
- this . clearEvent ?. content ?. reason ===
719
- "DecryptionError: The sender has disabled encrypting to unverified devices."
720
- ) ;
721
- }
722
-
723
713
public shouldAttemptDecryption ( ) : boolean {
724
714
if ( this . isRedacted ( ) ) return false ;
725
715
if ( this . isBeingDecrypted ( ) ) return false ;
@@ -913,9 +903,10 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
913
903
content : {
914
904
msgtype : "m.bad.encrypted" ,
915
905
body : "** Unable to decrypt: " + reason + " **" ,
916
- reason,
917
906
} ,
918
907
} ,
908
+ isEncryptedDisabledForUnverifiedDevices :
909
+ reason === "DecryptionError: The sender has disabled encrypting to unverified devices." ,
919
910
} ;
920
911
}
921
912
@@ -937,6 +928,8 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
937
928
this . claimedEd25519Key = decryptionResult . claimedEd25519Key ?? null ;
938
929
this . forwardingCurve25519KeyChain = decryptionResult . forwardingCurve25519KeyChain || [ ] ;
939
930
this . untrusted = decryptionResult . untrusted || false ;
931
+ this . isEncryptedDisabledForUnverifiedDevices =
932
+ decryptionResult . isEncryptedDisabledForUnverifiedDevices || false ;
940
933
this . invalidateExtensibleEvent ( ) ;
941
934
}
942
935
0 commit comments