1
1
import { useDispatch } from 'react-redux' ;
2
- import { getCachedNakedKeyFromBlindedNoServerPubkey } from '../../session/apis/open_group_api/sogsv3/knownBlindedkeys' ;
2
+ import {
3
+ findCachedBlindedMatchOrLookItUp ,
4
+ getCachedNakedKeyFromBlindedNoServerPubkey ,
5
+ } from '../../session/apis/open_group_api/sogsv3/knownBlindedkeys' ;
3
6
import { ConvoHub } from '../../session/conversations' ;
4
7
import { KeyPrefixType , PubKey } from '../../session/types' ;
5
8
import { updateUserProfileModal } from '../../state/ducks/modalDialog' ;
6
9
import { Data } from '../../data/data' ;
7
10
import type { WithMessageId } from '../../session/types/with' ;
8
- import { useIsMe , useIsPrivate } from '../../hooks/useParamSelector' ;
11
+ import { useIsMe , useIsPrivate , useIsPublic } from '../../hooks/useParamSelector' ;
9
12
import { useSelectedConversationKey } from '../../state/selectors/selectedConversation' ;
13
+ import { getSodiumRenderer } from '../../session/crypto' ;
14
+ import { OpenGroupData } from '../../data/opengroups' ;
10
15
11
16
/**
12
17
* Show the user details modal for a given message in the currently selected conversation.
@@ -15,6 +20,7 @@ export function useShowUserDetailsCbFromMessage() {
15
20
const dispatch = useDispatch ( ) ;
16
21
17
22
const selectedConvoKey = useSelectedConversationKey ( ) ;
23
+ const isPublic = useIsPublic ( selectedConvoKey ) ;
18
24
19
25
if ( ! selectedConvoKey ) {
20
26
throw new Error ( 'useShowUserDetailsCbFromMessage: no selected convo key' ) ;
@@ -37,8 +43,22 @@ export function useShowUserDetailsCbFromMessage() {
37
43
) ;
38
44
}
39
45
40
- const resolvedNakedId = getCachedNakedKeyFromBlindedNoServerPubkey ( sender ) ;
41
- const foundRealSessionId = resolvedNakedId !== sender ? resolvedNakedId : undefined ;
46
+ let foundRealSessionId : string | undefined ;
47
+ if ( PubKey . isBlinded ( sender ) && isPublic ) {
48
+ const openGroup = OpenGroupData . getV2OpenGroupRoom ( selectedConvoKey ) ;
49
+
50
+ if ( ! openGroup ) {
51
+ throw new Error ( 'useShowUserDetailsCbFromMessage: no open group found' ) ;
52
+ }
53
+ // Note: this is an expensive call
54
+ const resolvedNakedId = await findCachedBlindedMatchOrLookItUp (
55
+ sender ,
56
+ openGroup . serverPublicKey ,
57
+ await getSodiumRenderer ( )
58
+ ) ;
59
+ foundRealSessionId =
60
+ resolvedNakedId && resolvedNakedId !== sender ? resolvedNakedId : undefined ;
61
+ }
42
62
43
63
if ( foundRealSessionId && foundRealSessionId . startsWith ( KeyPrefixType . standard ) ) {
44
64
await ConvoHub . use ( ) . get ( sender ) . setOriginConversationID ( selectedConvoKey , true ) ;
0 commit comments