1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

add m.relates_to back to the content on the requesting side for e2e room

as it needs to be added to the commitment hash
as before, getContent() in an e2ee room doesn't return the relation
This commit is contained in:
Bruno Windels
2019-11-18 18:34:05 +01:00
parent 24ae787736
commit 3b02b62ba5
2 changed files with 15 additions and 1 deletions

View File

@@ -106,6 +106,17 @@ export default class VerificationBase extends EventEmitter {
}
}
_contentFromEventWithTxnId(event) {
if (this.roomId) { // verification as timeline event
// ensure m.related_to is included in e2ee rooms
// as the field is excluded from encryption
const content = Object.assign({}, event.getContent());
content["m.relates_to"] = event.getRelation();
return content;
} else { // verification as to_device event
return event.getContent();
}
}
/* creates a content object with the transaction id added to it */
_contentWithTxnId(content) {

View File

@@ -281,7 +281,10 @@ export default class SAS extends Base {
}
async _doRespondVerification() {
let content = this.startEvent.getContent();
// as m.related_to is not included in the encrypted content in e2e rooms,
// we need to make sure it is added
let content = this._contentFromEventWithTxnId(this.startEvent);
// Note: we intersect using our pre-made lists, rather than the sets,
// so that the result will be in our order of preference. Then
// fetching the first element from the array will give our preferred