{"record":{"id":"d85d3b7c47145007","repo":"RocketChat/Rocket.Chat","slug":"t-message-deleting-blocked","errorCode":null,"errorMessage":"t('Message_deleting_blocked')","messagePattern":"t\\('Message_deleting_blocked'\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/client/views/room/modals/DeleteMessageConfirmModal/DeleteMessageConfirmModal.tsx","lineNumber":31,"sourceCode":"\treject,\n\tonCancel,\n\tmessage,\n}: {\n\troom?: IRoom;\n\tchat: ChatAPI;\n\tresolve: () => void;\n\treject: (reason?: any) => void;\n\tmessage: IMessage;\n\tonCancel: () => void;\n}) => {\n\tconst { t } = useTranslation();\n\tconst mid = chat.currentEditingMessage.getMID();\n\tconst dispatchToastMessage = useToastMessageDispatch();\n\n\tconst deleteMessageMutation = useMutation({\n\t\tmutationFn: async () => {\n\t\t\tif (!(await chat.data.canDeleteMessage(message))) {\n\t\t\t\tthrow new Error(t('Message_deleting_blocked'));\n\t\t\t}\n\n\t\t\tawait chat.data.deleteMessage(message);\n\t\t},\n\t\tonSuccess: () => {\n\t\t\tif (mid === message._id) {\n\t\t\t\tchat.currentEditingMessage.stop();\n\t\t\t}\n\t\t\tchat.composer?.focus();\n\n\t\t\tdispatchToastMessage({ type: 'success', message: t('Your_entry_has_been_deleted') });\n\t\t\tresolve();\n\t\t},\n\t\tonError: (error) => {\n\t\t\tdispatchToastMessage({ type: 'error', message: error });\n\t\t\treject(error);\n\t\t},\n\t\tonSettled: () => {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/client/views/room/modals/DeleteMessageConfirmModal/DeleteMessageConfirmModal.tsx#L13-L49","documentation":"Thrown by the DeleteMessageConfirmModal mutation when chat.data.canDeleteMessage(message) resolves false. This check enforces the server's deletion policy (message ownership, delete permissions, Message_AllowDeleting and related settings) before any delete call is made, so the delete is blocked client-side with the localized 'Message_deleting_blocked' message.","triggerScenarios":"Clicking Delete on someone else's message without the force-delete permission; deleting your own message after Message_AllowDeleting_MustBeWithinTimeFrame elapsed; Message_AllowDeleting disabled workspace-wide; direct-message deletion restricted by Message_AllowDeleting_BlockDirectMessages; the message was already deleted so the permission check fails.","commonSituations":"Moderator UI shows a delete button that server policy then denies, time window for own-message deletion expired, role lost the delete-message permission, webhook/app-generated messages the user cannot delete.","solutions":["Verify the user's roles include delete-message (own messages) or force-delete-message-to-any-user (others' messages) in Admin > Permissions","Check Admin > Message settings: Message_AllowDeleting enabled, the deletion time frame, and DM restrictions","Refresh the room: the message may already be deleted, making canDeleteMessage fail on a stale reference"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const canDelete = await chat.data.canDeleteMessage(message);\nif (!canDelete) {\n\tdispatchToastMessage({ type: 'error', message: t('Message_deleting_blocked') });\n\treturn;\n}","typeGuard":null,"tryCatchPattern":"catch (error) {\n\t// already user-facing: surface the localized message, do not retry the mutation\n\tdispatchToastMessage({ type: 'error', message: error });\n}","preventionTips":["Hide the delete UI when the message is not deletable by the current user (check ownership + permissions up front)","Respect Message_AllowDeleting settings in feature flags/UI gating","Treat a false canDeleteMessage as final — do not bypass with a direct REST delete call"],"tags":["rocket-chat","messages","delete-message","permissions","client-validation"],"backgroundTag":"permission-denied","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}