diff --git a/src/domain/session/room/timeline/tiles/BaseMessageTile.js b/src/domain/session/room/timeline/tiles/BaseMessageTile.js index a348a249..2e7e5ad7 100644 --- a/src/domain/session/room/timeline/tiles/BaseMessageTile.js +++ b/src/domain/session/room/timeline/tiles/BaseMessageTile.js @@ -97,4 +97,8 @@ export class BaseMessageTile extends SimpleTile { this.emitChange("isContinuation"); } } + + redact(reason) { + this._room.sendRedaction(this._entry.id, reason); + } } diff --git a/src/domain/session/room/timeline/tiles/GapTile.js b/src/domain/session/room/timeline/tiles/GapTile.js index c2cf2f56..1b05c1c8 100644 --- a/src/domain/session/room/timeline/tiles/GapTile.js +++ b/src/domain/session/room/timeline/tiles/GapTile.js @@ -24,10 +24,6 @@ export class GapTile extends SimpleTile { this._error = null; } - get _room() { - return this.getOption("room"); - } - async fill() { // prevent doing this twice if (!this._loading) { diff --git a/src/domain/session/room/timeline/tiles/SimpleTile.js b/src/domain/session/room/timeline/tiles/SimpleTile.js index 977e2410..c4935f1d 100644 --- a/src/domain/session/room/timeline/tiles/SimpleTile.js +++ b/src/domain/session/room/timeline/tiles/SimpleTile.js @@ -118,4 +118,8 @@ export class SimpleTile extends ViewModel { super.dispose(); } // TilesCollection contract above + + get _room() { + return this.getOption("room"); + } } diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index c743dcb8..cb145b7d 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -297,6 +297,14 @@ export class Room extends BaseRoom { }); } + /** @public */ + sendRedaction(eventIdOrTxnId, reason, log = null) { + this._platform.logger.wrapOrRun(log, "redact", log => { + log.set("id", this.id); + return this._sendQueue.enqueueRedaction(eventIdOrTxnId, reason, log); + }); + } + /** @public */ async ensureMessageKeyIsShared(log = null) { if (!this._roomEncryption) { diff --git a/src/matrix/room/sending/SendQueue.js b/src/matrix/room/sending/SendQueue.js index 1ec789e7..c06669b6 100644 --- a/src/matrix/room/sending/SendQueue.js +++ b/src/matrix/room/sending/SendQueue.js @@ -201,6 +201,7 @@ export class SendQueue { async enqueueRedaction(eventIdOrTxnId, reason, log) { if (isTxnId(eventIdOrTxnId)) { + log.set("txnIdToRedact", eventIdOrTxnId); const txnId = eventIdOrTxnId; const pe = this._pendingEvents.array.find(pe => pe.txnId === txnId); if (pe && !pe.remoteId && pe.status !== SendStatus.Sending) { @@ -216,6 +217,8 @@ export class SendQueue { // and a bit complicated to fix. return; } + } else { + log.set("eventIdToRedact", eventIdOrTxnId); } await this._enqueueEvent(REDACTION_TYPE, {reason}, null, eventIdOrTxnId, log); }