Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Migrate broadcast MSC3912 redaction (#11014)
Browse files Browse the repository at this point in the history
  • Loading branch information
weeman1337 authored Jun 7, 2023
1 parent 4c73903 commit 1091e14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/components/views/dialogs/ConfirmRedactDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

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 { _t } from "../../../languageHandler";
Expand Down Expand Up @@ -72,7 +72,7 @@ export function createRedactEventDialog({
if (!proceed) return;

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
// server has support for relation based redactions
Expand All @@ -82,15 +82,15 @@ export function createRedactEventDialog({
relationBasedRedactionsSupport &&
relationBasedRedactionsSupport !== ServerSupport.Unsupported
) {
withRelations.with_relations = [RelationType.Reference];
withRelTypes.with_rel_types = [RelationType.Reference];
}
}

try {
onCloseDialog?.();
await cli.redactEvent(roomId, eventId, undefined, {
...(reason ? { reason } : {}),
...withRelations,
...withRelTypes,
});
} catch (e: any) {
const code = e.errcode || e.statusCode;
Expand Down
6 changes: 3 additions & 3 deletions test/components/views/dialogs/ConfirmRedactDialog-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("ConfirmRedactDialog", () => {
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, {});
});
});
Expand All @@ -110,9 +110,9 @@ describe("ConfirmRedactDialog", () => {
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, {
with_relations: [RelationType.Reference],
with_rel_types: [RelationType.Reference],
});
});
});
Expand Down

0 comments on commit 1091e14

Please sign in to comment.