From 1037dedc751ffac2bd4b719f7d0446919a6a9ae9 Mon Sep 17 00:00:00 2001 From: Ian Macdonald Date: Mon, 6 Feb 2023 02:00:29 +0100 Subject: [PATCH] When clicking avatar, ask before starting new private conversation. Even when we know the user's unblinded Session id, we probably don't want to start a conversation with him, so let's ask first. --- .../message/message-content/MessageAvatar.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ts/components/conversation/message/message-content/MessageAvatar.tsx b/ts/components/conversation/message/message-content/MessageAvatar.tsx index 741606859e..413a24265f 100644 --- a/ts/components/conversation/message/message-content/MessageAvatar.tsx +++ b/ts/components/conversation/message/message-content/MessageAvatar.tsx @@ -65,12 +65,12 @@ export const MessageAvatar = (props: Props) => { } const userName = authorName || authorProfileName || sender; + const convoWithSender = getConversationController().get(sender); const onMessageAvatarClick = useCallback(async () => { if (isPublic && !PubKey.hasBlindedPrefix(sender)) { // public chat but session id not blinded. disable showing user details if we do not have an active convo with that user. // an unactive convo with that user means that we never chatted with that id directyly, but only through a sogs - const convoWithSender = getConversationController().get(sender); if (!convoWithSender || !convoWithSender.get('active_at')) { // for some time, we might still get some unblinded messages, as in message sent unblinded because // * older clients still send unblinded message and those are allowed by sogs if they doesn't enforce blinding @@ -101,6 +101,20 @@ export const MessageAvatar = (props: Props) => { ); privateConvoToOpen = foundRealSessionId || privateConvoToOpen; + + if (foundRealSessionId && convoWithSender.get('active_at')) { + // We know this user's real id and have an active conversation with + // him. Go to it. + await getConversationController() + .get(privateConvoToOpen) + .setOriginConversationID(selectedConvoKey); + + await openConversationWithMessages({ conversationKey: privateConvoToOpen, messageId: null }); + + return; + } + // Public and blinded key for this message. Fall through to asking if we + // should start a conversation, which will send SOGS blinded message request. } await getConversationController()