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", "Error",
); );
const preservedContentFields = {
"m.room.message": [ "m.relates_to" ]
};
export class PendingEvent { export class PendingEvent {
constructor({data, remove, emitUpdate, attachments}) { constructor({data, remove, emitUpdate, attachments}) {
this._data = data; this._data = data;
@ -96,7 +100,20 @@ export class PendingEvent {
this._emitUpdate("status"); 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) { setEncrypted(type, content) {
this._preserveContentFields(content);
this._data.encryptedEventType = type; this._data.encryptedEventType = type;
this._data.encryptedContent = content; this._data.encryptedContent = content;
this._data.needsEncryption = false; this._data.needsEncryption = false;