From 24a75e3765260117d511a04973e5e580b6bf671d Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Jun 2019 13:46:34 +0200 Subject: [PATCH 1/3] return 'sending' status for an event that is only locally redacted --- src/models/event.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/models/event.js b/src/models/event.js index 50adc34a8..64ba6aed9 100644 --- a/src/models/event.js +++ b/src/models/event.js @@ -31,7 +31,7 @@ import logger from '../../src/logger'; * @readonly * @enum {string} */ -module.exports.EventStatus = { +const EventStatus = { /** The event was not sent and will no longer be retried. */ NOT_SENT: "not_sent", @@ -49,6 +49,7 @@ module.exports.EventStatus = { /** The event was cancelled before it was successfully sent. */ CANCELLED: "cancelled", }; +module.exports.EventStatus = EventStatus; const interns = {}; function intern(str) { @@ -877,16 +878,24 @@ utils.extend(module.exports.MatrixEvent.prototype, { }, /** - * Returns the status of the event, or the replacing event in case `makeReplace` has been called. + * Returns the status of any associated edit or redaction + * (not for reactions/annotations are their local echo doesn't affect the orignal event), + * or else the status of the event. * * @return {EventStatus} */ - replacementOrOwnStatus() { + getAssociatedLocalEchoStatus() { if (this._replacingEvent) { return this._replacingEvent.status; - } else { - return this.status; + } else if (this._locallyRedacted) { + const unsigned = this.event.unsigned; + const redactedBecause = unsigned && unsigned.redacted_because; + const redactionId = redactedBecause && redactedBecause.event_id; + if (redactionId && redactionId.startsWith("~")) { + return EventStatus.SENDING; + } } + return this.status; }, /** From 70b23614b57395952e704ad0f748775a6ca14647 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Jun 2019 14:55:58 +0200 Subject: [PATCH 2/3] comment typo --- src/models/event.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/event.js b/src/models/event.js index 64ba6aed9..1df624321 100644 --- a/src/models/event.js +++ b/src/models/event.js @@ -879,7 +879,7 @@ utils.extend(module.exports.MatrixEvent.prototype, { /** * Returns the status of any associated edit or redaction - * (not for reactions/annotations are their local echo doesn't affect the orignal event), + * (not for reactions/annotations as their local echo doesn't affect the orignal event), * or else the status of the event. * * @return {EventStatus} From bb5e3d51b8261cb0895b9eda1298511c78334907 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Jun 2019 14:58:17 +0200 Subject: [PATCH 3/3] remove redundant localecho part from method name --- src/models/event.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/event.js b/src/models/event.js index 1df624321..7fd8a2610 100644 --- a/src/models/event.js +++ b/src/models/event.js @@ -884,7 +884,7 @@ utils.extend(module.exports.MatrixEvent.prototype, { * * @return {EventStatus} */ - getAssociatedLocalEchoStatus() { + getAssociatedStatus() { if (this._replacingEvent) { return this._replacingEvent.status; } else if (this._locallyRedacted) {