Don't let users accidentally redact ACL events
Fixes https://github.com/vector-im/element-web/issues/15633 Fixes https://github.com/vector-im/element-web/issues/15632 Slightly more information is in the issues above and in the diff, however the short version is redacting an ACL event can obliterate a room which is bad.
This commit is contained in:
parent
294876f062
commit
b4de01b1f1
2 changed files with 10 additions and 2 deletions
|
@ -31,6 +31,7 @@ import SettingsStore from '../../../settings/SettingsStore';
|
||||||
import { isUrlPermitted } from '../../../HtmlUtils';
|
import { isUrlPermitted } from '../../../HtmlUtils';
|
||||||
import { isContentActionable } from '../../../utils/EventUtils';
|
import { isContentActionable } from '../../../utils/EventUtils';
|
||||||
import {MenuItem} from "../../structures/ContextMenu";
|
import {MenuItem} from "../../structures/ContextMenu";
|
||||||
|
import {EventType} from "matrix-js-sdk/src/@types/event";
|
||||||
|
|
||||||
function canCancel(eventStatus) {
|
function canCancel(eventStatus) {
|
||||||
return eventStatus === EventStatus.QUEUED || eventStatus === EventStatus.NOT_SENT;
|
return eventStatus === EventStatus.QUEUED || eventStatus === EventStatus.NOT_SENT;
|
||||||
|
@ -72,7 +73,10 @@ export default class MessageContextMenu extends React.Component {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
const room = cli.getRoom(this.props.mxEvent.getRoomId());
|
const room = cli.getRoom(this.props.mxEvent.getRoomId());
|
||||||
|
|
||||||
const canRedact = room.currentState.maySendRedactionForEvent(this.props.mxEvent, cli.credentials.userId);
|
// We explicitly decline to show the redact option on ACL events as it has a potential
|
||||||
|
// to obliterate the room - https://github.com/matrix-org/synapse/issues/4042
|
||||||
|
const canRedact = room.currentState.maySendRedactionForEvent(this.props.mxEvent, cli.credentials.userId)
|
||||||
|
&& this.props.mxEvent.getType() !== EventType.RoomServerAcl;
|
||||||
let canPin = room.currentState.mayClientSendStateEvent('m.room.pinned_events', cli);
|
let canPin = room.currentState.mayClientSendStateEvent('m.room.pinned_events', cli);
|
||||||
|
|
||||||
// HACK: Intentionally say we can't pin if the user doesn't want to use the functionality
|
// HACK: Intentionally say we can't pin if the user doesn't want to use the functionality
|
||||||
|
|
|
@ -60,6 +60,7 @@ import ErrorDialog from "../dialogs/ErrorDialog";
|
||||||
import QuestionDialog from "../dialogs/QuestionDialog";
|
import QuestionDialog from "../dialogs/QuestionDialog";
|
||||||
import ConfirmUserActionDialog from "../dialogs/ConfirmUserActionDialog";
|
import ConfirmUserActionDialog from "../dialogs/ConfirmUserActionDialog";
|
||||||
import InfoDialog from "../dialogs/InfoDialog";
|
import InfoDialog from "../dialogs/InfoDialog";
|
||||||
|
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||||
|
|
||||||
interface IDevice {
|
interface IDevice {
|
||||||
deviceId: string;
|
deviceId: string;
|
||||||
|
@ -586,7 +587,10 @@ const RedactMessagesButton: React.FC<IBaseProps> = ({member}) => {
|
||||||
while (timeline) {
|
while (timeline) {
|
||||||
eventsToRedact = timeline.getEvents().reduce((events, event) => {
|
eventsToRedact = timeline.getEvents().reduce((events, event) => {
|
||||||
if (event.getSender() === userId && !event.isRedacted() && !event.isRedaction() &&
|
if (event.getSender() === userId && !event.isRedacted() && !event.isRedaction() &&
|
||||||
event.getType() !== "m.room.create"
|
event.getType() !== EventType.RoomCreate &&
|
||||||
|
// Don't redact ACLs because that'll obliterate the room
|
||||||
|
// See https://github.com/matrix-org/synapse/issues/4042 for details.
|
||||||
|
event.getType() !== EventType.RoomServerAcl
|
||||||
) {
|
) {
|
||||||
return events.concat(event);
|
return events.concat(event);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue