Rename pending event fields

This commit is contained in:
Danila Fedorin 2021-08-06 10:27:17 -07:00
parent 1207203b00
commit ac044cb5c2
2 changed files with 6 additions and 6 deletions

View file

@ -28,7 +28,7 @@ export const SendStatus = createEnum(
"Error",
);
const preservedContentFields = [ "m.relates_to" ];
const unencryptedContentFields = [ "m.relates_to" ];
export class PendingEvent {
constructor({data, remove, emitUpdate, attachments}) {
@ -98,9 +98,9 @@ export class PendingEvent {
this._emitUpdate("status");
}
get cleanedContent() {
get contentForEncryption() {
const content = Object.assign({}, this._data.content);
for (const field of preservedContentFields) {
for (const field of unencryptedContentFields) {
delete content[field];
}
return content;
@ -108,7 +108,7 @@ export class PendingEvent {
_preserveContentFields(into) {
const content = this._data.content;
for (const field of preservedContentFields) {
for (const field of unencryptedContentFields) {
if (content[field] !== undefined) {
into[field] = content[field];
}

View file

@ -97,9 +97,9 @@ export class SendQueue {
}
if (pendingEvent.needsEncryption) {
pendingEvent.setEncrypting();
const cleanedContent = pendingEvent.cleanedContent;
const encryptionContent = pendingEvent.contentForEncryption;
const {type, content} = await log.wrap("encrypt", log => this._roomEncryption.encrypt(
pendingEvent.eventType, cleanedContent, this._hsApi, log));
pendingEvent.eventType, encryptionContent, this._hsApi, log));
pendingEvent.setEncrypted(type, content);
await this._tryUpdateEvent(pendingEvent);
}