core: group link contact connecting(ed) events to avoid adding previews in ui (#1242)

* core: group link contact connecting(ed) events to avoid adding ui previews

* fix test

* refactor

* ios types

* android types

* type in bot
This commit is contained in:
JRoberts
2022-10-24 00:18:15 +04:00
committed by GitHub
parent 341199d599
commit 15c1f9f9c8
11 changed files with 67 additions and 47 deletions
+8 -6
View File
@@ -832,11 +832,11 @@ processChatCommand = \case
(agentConnId, cReq) <- withAgent $ \a -> createConnection a True SCMInvitation
member <- withStore $ \db -> createNewContactMember db gVar user groupId contact memRole agentConnId cReq
sendInvitation member cReq
pure $ CRSentGroupInvitation gInfo contact member
pure $ CRSentGroupInvitation gInfo contact member False
Just member@GroupMember {groupMemberId, memberStatus}
| memberStatus == GSMemInvited ->
withStore' (\db -> getMemberInvitation db user groupMemberId) >>= \case
Just cReq -> sendInvitation member cReq $> CRSentGroupInvitation gInfo contact member
Just cReq -> sendInvitation member cReq $> CRSentGroupInvitation gInfo contact member False
Nothing -> throwChatError $ CEGroupCantResendInvitation gInfo cName
| otherwise -> throwChatError $ CEGroupDuplicateMember cName
APIJoinGroup groupId -> withUser $ \user@User {userId} -> do
@@ -1685,7 +1685,8 @@ processAgentMessage (Just user@User {userId, profile}) corrId agentConnId agentM
Nothing -> do
-- [incognito] print incognito profile used for this contact
incognitoProfile <- forM customUserProfileId $ \profileId -> withStore (\db -> getProfileById db userId profileId)
toView $ CRContactConnected ct (fmap fromLocalProfile incognitoProfile)
viaGroupLink <- withStore' (\db -> getConnectionViaGroupLinkFlag db user connId)
toView $ CRContactConnected ct (fmap fromLocalProfile incognitoProfile) (fromMaybe False viaGroupLink)
setActive $ ActiveC c
showToast (c <> "> ") "connected"
forM_ viaUserContactLink $ \userContactLinkId ->
@@ -1749,7 +1750,7 @@ processAgentMessage (Just user@User {userId, profile}) corrId agentConnId agentM
Just ct -> do
withStore' $ \db -> setNewContactMemberConnRequest db user m cReq
sendGrpInvitation ct m
toView $ CRSentGroupInvitationViaLink gInfo ct m
toView $ CRSentGroupInvitation gInfo ct m True
where
sendGrpInvitation :: Contact -> GroupMember -> m ()
sendGrpInvitation ct GroupMember {memberId, memberRole = memRole} = do
@@ -2533,12 +2534,13 @@ processAgentMessage (Just user@User {userId, profile}) corrId agentConnId agentM
toView $ CRContactsMerged to from
saveConnInfo :: Connection -> ConnInfo -> m ()
saveConnInfo activeConn connInfo = do
saveConnInfo activeConn@Connection {connId} connInfo = do
ChatMessage {chatMsgEvent} <- parseChatMessage connInfo
case chatMsgEvent of
XInfo p -> do
ct <- withStore $ \db -> createDirectContact db userId activeConn p
toView $ CRContactConnecting ct
viaGroupLink <- withStore' (\db -> getConnectionViaGroupLinkFlag db user connId)
toView $ CRContactConnecting ct (fromMaybe False viaGroupLink)
-- TODO show/log error, other events in SMP confirmation
_ -> pure ()