forked from mystiq/hydrogen-web
Rename pending event fields
This commit is contained in:
parent
1207203b00
commit
ac044cb5c2
2 changed files with 6 additions and 6 deletions
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue