You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Merge remote-tracking branch 'upstream/develop' into improve-event-clear-event-state
This commit is contained in:
@@ -262,6 +262,16 @@ export class MatrixEvent extends EventEmitter {
|
||||
this.localTimestamp = Date.now() - this.getAge();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the event as though it would appear unencrypted. If the event is already not
|
||||
* encrypted, it is simply returned as-is.
|
||||
* @returns {IEvent} The event in wire format.
|
||||
*/
|
||||
public getEffectiveEvent(): IEvent {
|
||||
// clearEvent doesn't have all the fields, so we'll copy what we can from this.event
|
||||
return Object.assign({}, this.event, this.clearEvent) as IEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event_id for this event.
|
||||
* @return {string} The event ID, e.g. <code>$143350589368169JsLZx:localhost
|
||||
@@ -1232,20 +1242,7 @@ export class MatrixEvent extends EventEmitter {
|
||||
* @return {Object}
|
||||
*/
|
||||
public toJSON(): object {
|
||||
const event: any = {
|
||||
type: this.getType(),
|
||||
sender: this.getSender(),
|
||||
content: this.getContent(),
|
||||
event_id: this.getId(),
|
||||
origin_server_ts: this.getTs(),
|
||||
unsigned: this.getUnsigned(),
|
||||
room_id: this.getRoomId(),
|
||||
};
|
||||
|
||||
// if this is a redaction then attach the redacts key
|
||||
if (this.isRedaction()) {
|
||||
event.redacts = this.event.redacts;
|
||||
}
|
||||
const event = this.getEffectiveEvent();
|
||||
|
||||
if (!this.isEncrypted()) {
|
||||
return event;
|
||||
|
||||
Reference in New Issue
Block a user