Merge branch 'encryption-fix-relatesto' into 'master'

[Room] Fix relates to key while encryption

See merge request famedly/famedlysdk!263
This commit is contained in:
Christian Pauly 2020-04-20 10:56:36 +00:00
commit 78667536c5

View file

@ -1668,6 +1668,7 @@ class Room {
if (_outboundGroupSession == null) { if (_outboundGroupSession == null) {
await createOutboundGroupSession(); await createOutboundGroupSession();
} }
final Map<String, dynamic> mRelatesTo = payload.remove('m.relates_to');
final payloadContent = { final payloadContent = {
'content': payload, 'content': payload,
'type': type, 'type': type,
@ -1679,6 +1680,7 @@ class Room {
'device_id': client.deviceID, 'device_id': client.deviceID,
'sender_key': client.identityKey, 'sender_key': client.identityKey,
'session_id': _outboundGroupSession.session_id(), 'session_id': _outboundGroupSession.session_id(),
if (mRelatesTo != null) 'm.relates_to': mRelatesTo,
}; };
await _storeOutboundGroupSession(); await _storeOutboundGroupSession();
return encryptedPayload; return encryptedPayload;
@ -1736,6 +1738,10 @@ class Room {
}; };
} }
} }
if (event.content['m.relates_to'] != null) {
decryptedPayload['content']['m.relates_to'] =
event.content['m.relates_to'];
}
return Event( return Event(
content: decryptedPayload['content'], content: decryptedPayload['content'],
typeKey: decryptedPayload['type'], typeKey: decryptedPayload['type'],