Migrate broadcast MSC3912 redaction (#11014)

This commit is contained in:
Michael Weimann 2023-06-07 15:24:01 +02:00 committed by GitHub
parent 4c73903274
commit 1091e14a3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import { Feature, ServerSupport } from "matrix-js-sdk/src/feature"; import { Feature, ServerSupport } from "matrix-js-sdk/src/feature";
import { MatrixEvent, RelationType } from "matrix-js-sdk/src/matrix"; import { IRedactOpts, MatrixEvent, RelationType } from "matrix-js-sdk/src/matrix";
import React from "react"; import React from "react";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
@ -72,7 +72,7 @@ export function createRedactEventDialog({
if (!proceed) return; if (!proceed) return;
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
const withRelations: { with_relations?: RelationType[] } = {}; const withRelTypes: Pick<IRedactOpts, "with_rel_types"> = {};
// redact related events if this is a voice broadcast started event and // redact related events if this is a voice broadcast started event and
// server has support for relation based redactions // server has support for relation based redactions
@ -82,7 +82,7 @@ export function createRedactEventDialog({
relationBasedRedactionsSupport && relationBasedRedactionsSupport &&
relationBasedRedactionsSupport !== ServerSupport.Unsupported relationBasedRedactionsSupport !== ServerSupport.Unsupported
) { ) {
withRelations.with_relations = [RelationType.Reference]; withRelTypes.with_rel_types = [RelationType.Reference];
} }
} }
@ -90,7 +90,7 @@ export function createRedactEventDialog({
onCloseDialog?.(); onCloseDialog?.();
await cli.redactEvent(roomId, eventId, undefined, { await cli.redactEvent(roomId, eventId, undefined, {
...(reason ? { reason } : {}), ...(reason ? { reason } : {}),
...withRelations, ...withRelTypes,
}); });
} catch (e: any) { } catch (e: any) {
const code = e.errcode || e.statusCode; const code = e.errcode || e.statusCode;

View file

@ -94,7 +94,7 @@ describe("ConfirmRedactDialog", () => {
await confirmDeleteVoiceBroadcastStartedEvent(); await confirmDeleteVoiceBroadcastStartedEvent();
}); });
it("should call redact without `with_relations`", () => { it("should call redact without `with_rel_types`", () => {
expect(client.redactEvent).toHaveBeenCalledWith(roomId, mxEvent.getId(), undefined, {}); expect(client.redactEvent).toHaveBeenCalledWith(roomId, mxEvent.getId(), undefined, {});
}); });
}); });
@ -110,9 +110,9 @@ describe("ConfirmRedactDialog", () => {
await confirmDeleteVoiceBroadcastStartedEvent(); await confirmDeleteVoiceBroadcastStartedEvent();
}); });
it("should call redact with `with_relations`", () => { it("should call redact with `with_rel_types`", () => {
expect(client.redactEvent).toHaveBeenCalledWith(roomId, mxEvent.getId(), undefined, { expect(client.redactEvent).toHaveBeenCalledWith(roomId, mxEvent.getId(), undefined, {
with_relations: [RelationType.Reference], with_rel_types: [RelationType.Reference],
}); });
}); });
}); });