don't aggregate relations on redacted events

This commit is contained in:
Bruno Windels 2021-06-16 18:00:50 +02:00
parent ce5409dc26
commit 150f58a6b3
3 changed files with 9 additions and 5 deletions

View file

@ -21,3 +21,7 @@ export function getPrevContentFromStateEvent(event) {
} }
export const REDACTION_TYPE = "m.room.redaction"; export const REDACTION_TYPE = "m.room.redaction";
export function isRedacted(event) {
return !!event?.unsigned?.redacted_because;
}

View file

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import {BaseEventEntry} from "./BaseEventEntry.js"; import {BaseEventEntry} from "./BaseEventEntry.js";
import {getPrevContentFromStateEvent} from "../../common.js"; import {getPrevContentFromStateEvent, isRedacted} from "../../common.js";
import {getRelatedEventId} from "../relations.js"; import {getRelatedEventId} from "../relations.js";
export class EventEntry extends BaseEventEntry { export class EventEntry extends BaseEventEntry {
@ -115,7 +115,7 @@ export class EventEntry extends BaseEventEntry {
} }
get isRedacted() { get isRedacted() {
return super.isRedacted || !!this._eventEntry.event.unsigned?.redacted_because; return super.isRedacted || isRedacted(this._eventEntry.event);
} }
get redactionReason() { get redactionReason() {

View file

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import {EventEntry} from "../entries/EventEntry.js"; 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"; import {ANNOTATION_RELATION_TYPE, getRelation} from "../relations.js";
export class RelationWriter { export class RelationWriter {
@ -58,7 +58,7 @@ export class RelationWriter {
const result = await this.writeRelation(sourceEntry, txn, log); const result = await this.writeRelation(sourceEntry, txn, log);
// when back-paginating, it can also happen that we've received relations // 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. // 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); const relations = await txn.timelineRelations.getAllForTarget(this._roomId, sourceEntry.id);
if (relations.length) { if (relations.length) {
for (const r of relations) { for (const r of relations) {
@ -99,7 +99,7 @@ export class RelationWriter {
}); });
} else { } else {
const relation = getRelation(sourceEntry.event); const relation = getRelation(sourceEntry.event);
if (relation) { if (relation && !isRedacted(targetStorageEntry.event)) {
const relType = relation.rel_type; const relType = relation.rel_type;
if (relType === ANNOTATION_RELATION_TYPE) { if (relType === ANNOTATION_RELATION_TYPE) {
const aggregated = log.wrap("react", log => { const aggregated = log.wrap("react", log => {