From 925136d016ecd48bbbef8087944131544d1b55fb Mon Sep 17 00:00:00 2001 From: Germain Date: Mon, 22 Nov 2021 17:17:05 +0000 Subject: [PATCH] Disallow KeyVerificationRequest as thread root (#7182) --- src/Notifier.ts | 13 +++++++------ .../views/messages/MessageActionBar.tsx | 19 +++++++++++++++++-- src/components/views/rooms/EventTile.tsx | 4 ++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/Notifier.ts b/src/Notifier.ts index 1acd028b08..c03655f209 100644 --- a/src/Notifier.ts +++ b/src/Notifier.ts @@ -39,6 +39,7 @@ import { mediaFromMxc } from "./customisations/Media"; import ErrorDialog from "./components/views/dialogs/ErrorDialog"; import { logger } from "matrix-js-sdk/src/logger"; +import { MsgType } from "matrix-js-sdk/src/@types/event"; /* * Dispatches: @@ -55,8 +56,8 @@ Override both the content body and the TextForEvent handler for specific msgtype This is useful when the content body contains fallback text that would explain that the client can't handle a particular type of tile. */ -const typehandlers = { - "m.key.verification.request": (event) => { +const msgTypeHandlers = { + [MsgType.KeyVerificationRequest]: (event) => { const name = (event.sender || {}).name; return _t("%(name)s is requesting verification", { name }); }, @@ -71,8 +72,8 @@ export const Notifier = { pendingEncryptedEventIds: [], notificationMessageForEvent: function(ev: MatrixEvent): string { - if (typehandlers.hasOwnProperty(ev.getContent().msgtype)) { - return typehandlers[ev.getContent().msgtype](ev); + if (msgTypeHandlers.hasOwnProperty(ev.getContent().msgtype)) { + return msgTypeHandlers[ev.getContent().msgtype](ev); } return TextForEvent.textForEvent(ev); }, @@ -97,7 +98,7 @@ export const Notifier = { title = room.name; // notificationMessageForEvent includes sender, // but we already have the sender here - if (ev.getContent().body && !typehandlers.hasOwnProperty(ev.getContent().msgtype)) { + if (ev.getContent().body && !msgTypeHandlers.hasOwnProperty(ev.getContent().msgtype)) { msg = ev.getContent().body; } } else if (ev.getType() === 'm.room.member') { @@ -108,7 +109,7 @@ export const Notifier = { title = ev.sender.name + " (" + room.name + ")"; // notificationMessageForEvent includes sender, // but we've just out sender in the title - if (ev.getContent().body && !typehandlers.hasOwnProperty(ev.getContent().msgtype)) { + if (ev.getContent().body && !msgTypeHandlers.hasOwnProperty(ev.getContent().msgtype)) { msg = ev.getContent().body; } } diff --git a/src/components/views/messages/MessageActionBar.tsx b/src/components/views/messages/MessageActionBar.tsx index 1831e2da12..2b0faa210a 100644 --- a/src/components/views/messages/MessageActionBar.tsx +++ b/src/components/views/messages/MessageActionBar.tsx @@ -42,6 +42,7 @@ import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks'; import ReplyChain from '../elements/ReplyChain'; import { dispatchShowThreadEvent } from '../../../dispatcher/dispatch-actions/threads'; import ReactionPicker from "../emojipicker/ReactionPicker"; +import { MsgType } from 'matrix-js-sdk/src/@types/event'; interface IOptionsButtonProps { mxEvent: MatrixEvent; @@ -210,6 +211,21 @@ export default class MessageActionBar extends React.PureComponent - { (SettingsStore.getValue("feature_thread") - && this.context.timelineRenderingType !== TimelineRenderingType.Thread) && ( + { (this.showReplyInThreadAction) && (