diff --git a/src/matrix/room/common.js b/src/matrix/room/common.js index 721160e6..b009a89c 100644 --- a/src/matrix/room/common.js +++ b/src/matrix/room/common.js @@ -21,3 +21,7 @@ export function getPrevContentFromStateEvent(event) { } export const REDACTION_TYPE = "m.room.redaction"; + +export function isRedacted(event) { + return !!event?.unsigned?.redacted_because; +} diff --git a/src/matrix/room/timeline/entries/EventEntry.js b/src/matrix/room/timeline/entries/EventEntry.js index 2aa9cba0..3a6889f7 100644 --- a/src/matrix/room/timeline/entries/EventEntry.js +++ b/src/matrix/room/timeline/entries/EventEntry.js @@ -15,7 +15,7 @@ limitations under the License. */ import {BaseEventEntry} from "./BaseEventEntry.js"; -import {getPrevContentFromStateEvent} from "../../common.js"; +import {getPrevContentFromStateEvent, isRedacted} from "../../common.js"; import {getRelatedEventId} from "../relations.js"; export class EventEntry extends BaseEventEntry { @@ -115,7 +115,7 @@ export class EventEntry extends BaseEventEntry { } get isRedacted() { - return super.isRedacted || !!this._eventEntry.event.unsigned?.redacted_because; + return super.isRedacted || isRedacted(this._eventEntry.event); } get redactionReason() { diff --git a/src/matrix/room/timeline/persistence/RelationWriter.js b/src/matrix/room/timeline/persistence/RelationWriter.js index 13b0014d..853dcb0b 100644 --- a/src/matrix/room/timeline/persistence/RelationWriter.js +++ b/src/matrix/room/timeline/persistence/RelationWriter.js @@ -15,7 +15,7 @@ limitations under the License. */ import {EventEntry} from "../entries/EventEntry.js"; -import {REDACTION_TYPE} from "../../common.js"; +import {REDACTION_TYPE, isRedacted} from "../../common.js"; import {ANNOTATION_RELATION_TYPE, getRelation} from "../relations.js"; export class RelationWriter { @@ -58,7 +58,7 @@ export class RelationWriter { const result = await this.writeRelation(sourceEntry, txn, log); // when back-paginating, it can also happen that we've received relations // for this event before, which now upon receiving the target need to be aggregated. - if (direction.isBackward) { + if (direction.isBackward && !isRedacted(storageEntry.event)) { const relations = await txn.timelineRelations.getAllForTarget(this._roomId, sourceEntry.id); if (relations.length) { for (const r of relations) { @@ -99,7 +99,7 @@ export class RelationWriter { }); } else { const relation = getRelation(sourceEntry.event); - if (relation) { + if (relation && !isRedacted(targetStorageEntry.event)) { const relType = relation.rel_type; if (relType === ANNOTATION_RELATION_TYPE) { const aggregated = log.wrap("react", log => {