From ffad8063664bb16a71788e732e999e949c17e7e7 Mon Sep 17 00:00:00 2001 From: warrickct Date: Thu, 17 Feb 2022 20:29:31 +1100 Subject: [PATCH] Prevent attachments being sent for unapproved conversations. --- _locales/en/messages.json | 1 + ts/components/conversation/composition/CompositionBox.tsx | 7 +++++++ ts/session/utils/Toast.tsx | 4 ++++ ts/types/LocalizerKeys.ts | 1 + 4 files changed, 13 insertions(+) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e099f4687..f3b22f54b 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -473,5 +473,6 @@ "hideRequestBanner": "Hide Message Request Banner", "openMessageRequestInbox": "View Message Requests", "noMessageRequestsPending": "No pending message requests", + "noMediaUntilApproved": "You cannot send attachments until the conversation is approved", "openMessageRequestInboxDescription": "View your Message Request inbox" } diff --git a/ts/components/conversation/composition/CompositionBox.tsx b/ts/components/conversation/composition/CompositionBox.tsx index 32288a196..74f83af83 100644 --- a/ts/components/conversation/composition/CompositionBox.tsx +++ b/ts/components/conversation/composition/CompositionBox.tsx @@ -729,6 +729,13 @@ class CompositionBoxInner extends React.Component { } private onChooseAttachment() { + if ( + !this.props.selectedConversation?.didApproveMe && + this.props.selectedConversation?.isPrivate + ) { + ToastUtils.pushNoMediaUntilApproved(); + return; + } this.fileInput.current?.click(); } diff --git a/ts/session/utils/Toast.tsx b/ts/session/utils/Toast.tsx index 259d240a0..dd90f7f24 100644 --- a/ts/session/utils/Toast.tsx +++ b/ts/session/utils/Toast.tsx @@ -279,3 +279,7 @@ export function pushNoAudioInputFound() { export function pushNoAudioOutputFound() { pushToastWarning('noAudioInputFound', window.i18n('noAudioOutputFound')); } + +export function pushNoMediaUntilApproved() { + pushToastError('noMediaUntilApproved', window.i18n('noMediaUntilApproved')); +} diff --git a/ts/types/LocalizerKeys.ts b/ts/types/LocalizerKeys.ts index 6c0f29db7..f51c1eaee 100644 --- a/ts/types/LocalizerKeys.ts +++ b/ts/types/LocalizerKeys.ts @@ -476,4 +476,5 @@ export type LocalizerKeys = | 'openMessageRequestInboxDescription' | 'hideRequestBanner' | 'noMessageRequestsPending' + | 'noMediaUntilApproved' | 'reportIssue';