diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index 621dee38a..d39beb8d3 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -298,6 +298,7 @@ export async function deleteAllMessagesByConvoIdNoConfirmation(conversationId: s lastMessage: null, unreadCount: 0, mentionedUs: false, + isApproved: false, }); await conversation.commit(); diff --git a/ts/receiver/contentMessage.ts b/ts/receiver/contentMessage.ts index 56b90cefd..1cf793d08 100644 --- a/ts/receiver/contentMessage.ts +++ b/ts/receiver/contentMessage.ts @@ -371,19 +371,38 @@ export async function innerHandleSwarmContentMessage( ); } - const newConvo = await getConversationController().getOrCreateAndWait( + const convo = await getConversationController().getOrCreateAndWait( envelope.source, ConversationTypeEnum.PRIVATE ); if ( - newConvo.isPrivate() && - !newConvo.isApproved() && + convo.isPrivate() && + !convo.isApproved() && window.inboxStore?.getState().userConfig.hideMessageRequests ) { window.inboxStore?.dispatch(showMessageRequestBanner()); } + // For edge case when messaging a client that's unable to explicitly send request approvals + if (!convo.didApproveMe() && convo.isPrivate() && convo.isApproved()) { + convo.setDidApproveMe(true); + // Conversation was not approved before so a sync is needed + convo.addSingleMessage({ + conversationId: convo.get('id'), + source: envelope.source, + type: 'outgoing', // mark it as outgoing just so it appears below our sent attachment + sent_at: _.toNumber(envelope.timestamp), // TODO: maybe add timestamp to messageRequestResponse? confirm it doesn't exist first + received_at: Date.now(), + messageRequestResponse: { + isApproved: 1, + }, + unread: 1, // 1 means unread + expireTimer: 0, + }); + convo.updateLastMessage(); + } + if (content.dataMessage) { if (content.dataMessage.profileKey && content.dataMessage.profileKey.length === 0) { content.dataMessage.profileKey = null;