Preserve the m.relates_to field for message.

This commit is contained in:
Danila Fedorin 2021-07-30 14:37:34 -07:00
parent d4ed146cd7
commit 9bd7d1397c

View file

@ -28,6 +28,10 @@ export const SendStatus = createEnum(
"Error",
);
const preservedContentFields = {
"m.room.message": [ "m.relates_to" ]
};
export class PendingEvent {
constructor({data, remove, emitUpdate, attachments}) {
this._data = data;
@ -96,7 +100,20 @@ export class PendingEvent {
this._emitUpdate("status");
}
_preserveContentFields(into) {
const preservedFields = preservedContentFields[this.eventType];
if (preservedFields) {
const content = this._data.content;
for (const field of preservedFields) {
if (content[field] !== undefined) {
into[field] = content[field];
}
}
}
}
setEncrypted(type, content) {
this._preserveContentFields(content);
this._data.encryptedEventType = type;
this._data.encryptedContent = content;
this._data.needsEncryption = false;