mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Adding handling of edge case for messaging clients without request approval update.
This commit is contained in:
parent
6a02846829
commit
c3d9912572
2 changed files with 23 additions and 3 deletions
|
@ -298,6 +298,7 @@ export async function deleteAllMessagesByConvoIdNoConfirmation(conversationId: s
|
|||
lastMessage: null,
|
||||
unreadCount: 0,
|
||||
mentionedUs: false,
|
||||
isApproved: false,
|
||||
});
|
||||
|
||||
await conversation.commit();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue