From c0622d47f4f53b0e15bf114dc623381fb7eda483 Mon Sep 17 00:00:00 2001 From: warrickct Date: Thu, 17 Feb 2022 22:19:52 +1100 Subject: [PATCH] Disallow disappearing messages if convo is not approved by recipient. --- _locales/en/messages.json | 1 + ts/interactions/conversationInteractions.ts | 5 +++++ ts/models/conversation.ts | 6 +----- ts/session/utils/Toast.tsx | 4 ++++ ts/types/LocalizerKeys.ts | 1 + 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f3b22f54b..2a62e6768 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -474,5 +474,6 @@ "openMessageRequestInbox": "View Message Requests", "noMessageRequestsPending": "No pending message requests", "noMediaUntilApproved": "You cannot send attachments until the conversation is approved", + "mustBeApproved": "This conversation must be accepted to use this feature", "openMessageRequestInboxDescription": "View your Message Request inbox" } diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index 24297a522..aa59d248f 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -334,6 +334,11 @@ export async function setDisappearingMessagesByConvoId( ) { const conversation = getConversationController().get(conversationId); + if (!conversation.didApproveMe()) { + ToastUtils.pushMustBeApproved(); + return; + } + if (!seconds || seconds <= 0) { await conversation.updateExpireTimer(null); } else { diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 5a91483d1..da4504bff 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -928,11 +928,7 @@ export class ConversationModel extends Backbone.Model { // for handling edge case for syncing/linking devices. // if convo has a message by us, we have replied - which is considered as approved // if (!this.isMe()) { - if (!this.isMe()) { - if (!this.isApproved() && this.isPrivate()) { - this.setIsApproved(true); - } - } + // if (!this.isApproved() && this.isPrivate()) { // this.setIsApproved(true); // } // } diff --git a/ts/session/utils/Toast.tsx b/ts/session/utils/Toast.tsx index dd90f7f24..d6b22bd2f 100644 --- a/ts/session/utils/Toast.tsx +++ b/ts/session/utils/Toast.tsx @@ -283,3 +283,7 @@ export function pushNoAudioOutputFound() { export function pushNoMediaUntilApproved() { pushToastError('noMediaUntilApproved', window.i18n('noMediaUntilApproved')); } + +export function pushMustBeApproved() { + pushToastError('mustBeApproved', window.i18n('mustBeApproved')); +} diff --git a/ts/types/LocalizerKeys.ts b/ts/types/LocalizerKeys.ts index f51c1eaee..9fe29aff6 100644 --- a/ts/types/LocalizerKeys.ts +++ b/ts/types/LocalizerKeys.ts @@ -477,4 +477,5 @@ export type LocalizerKeys = | 'hideRequestBanner' | 'noMessageRequestsPending' | 'noMediaUntilApproved' + | 'mustBeApproved' | 'reportIssue';