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

Commit e67db10

Browse files
authored
Merge pull request #5384 from matrix-org/travis/redact-acl
Don't let users accidentally redact ACL events
2 parents 294876f + b4de01b commit e67db10

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/components/views/context_menus/MessageContextMenu.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import SettingsStore from '../../../settings/SettingsStore';
3131
import { isUrlPermitted } from '../../../HtmlUtils';
3232
import { isContentActionable } from '../../../utils/EventUtils';
3333
import {MenuItem} from "../../structures/ContextMenu";
34+
import {EventType} from "matrix-js-sdk/src/@types/event";
3435

3536
function canCancel(eventStatus) {
3637
return eventStatus === EventStatus.QUEUED || eventStatus === EventStatus.NOT_SENT;
@@ -72,7 +73,10 @@ export default class MessageContextMenu extends React.Component {
7273
const cli = MatrixClientPeg.get();
7374
const room = cli.getRoom(this.props.mxEvent.getRoomId());
7475

75-
const canRedact = room.currentState.maySendRedactionForEvent(this.props.mxEvent, cli.credentials.userId);
76+
// We explicitly decline to show the redact option on ACL events as it has a potential
77+
// to obliterate the room - https://github.com/matrix-org/synapse/issues/4042
78+
const canRedact = room.currentState.maySendRedactionForEvent(this.props.mxEvent, cli.credentials.userId)
79+
&& this.props.mxEvent.getType() !== EventType.RoomServerAcl;
7680
let canPin = room.currentState.mayClientSendStateEvent('m.room.pinned_events', cli);
7781

7882
// HACK: Intentionally say we can't pin if the user doesn't want to use the functionality

src/components/views/right_panel/UserInfo.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import ErrorDialog from "../dialogs/ErrorDialog";
6060
import QuestionDialog from "../dialogs/QuestionDialog";
6161
import ConfirmUserActionDialog from "../dialogs/ConfirmUserActionDialog";
6262
import InfoDialog from "../dialogs/InfoDialog";
63+
import { EventType } from "matrix-js-sdk/src/@types/event";
6364

6465
interface IDevice {
6566
deviceId: string;
@@ -586,7 +587,10 @@ const RedactMessagesButton: React.FC<IBaseProps> = ({member}) => {
586587
while (timeline) {
587588
eventsToRedact = timeline.getEvents().reduce((events, event) => {
588589
if (event.getSender() === userId && !event.isRedacted() && !event.isRedaction() &&
589-
event.getType() !== "m.room.create"
590+
event.getType() !== EventType.RoomCreate &&
591+
// Don't redact ACLs because that'll obliterate the room
592+
// See https://github.com/matrix-org/synapse/issues/4042 for details.
593+
event.getType() !== EventType.RoomServerAcl
590594
) {
591595
return events.concat(event);
592596
} else {

0 commit comments

Comments
 (0)