core: rename conn vrange into peer vrange (#3023)
This commit is contained in:
parent
0c4b843a3f
commit
e6baca5610
@ -1441,12 +1441,12 @@ processChatCommand = \case
|
|||||||
inv@ReceivedGroupInvitation {fromMember} <- getGroupInvitation db user groupId
|
inv@ReceivedGroupInvitation {fromMember} <- getGroupInvitation db user groupId
|
||||||
(inv,) <$> getContactViaMember db user fromMember
|
(inv,) <$> getContactViaMember db user fromMember
|
||||||
let ReceivedGroupInvitation {fromMember, connRequest, groupInfo = g@GroupInfo {membership}} = invitation
|
let ReceivedGroupInvitation {fromMember, connRequest, groupInfo = g@GroupInfo {membership}} = invitation
|
||||||
Contact {activeConn = Connection {connChatVRange}} = ct
|
Contact {activeConn = Connection {peerChatVRange}} = ct
|
||||||
withChatLock "joinGroup" . procCmd $ do
|
withChatLock "joinGroup" . procCmd $ do
|
||||||
dm <- directMessage $ XGrpAcpt (memberId (membership :: GroupMember))
|
dm <- directMessage $ XGrpAcpt (memberId (membership :: GroupMember))
|
||||||
agentConnId <- withAgent $ \a -> joinConnection a (aUserId user) True connRequest dm
|
agentConnId <- withAgent $ \a -> joinConnection a (aUserId user) True connRequest dm
|
||||||
withStore' $ \db -> do
|
withStore' $ \db -> do
|
||||||
createMemberConnection db userId fromMember agentConnId connChatVRange
|
createMemberConnection db userId fromMember agentConnId peerChatVRange
|
||||||
updateGroupMemberStatus db userId fromMember GSMemAccepted
|
updateGroupMemberStatus db userId fromMember GSMemAccepted
|
||||||
updateGroupMemberStatus db userId membership GSMemAccepted
|
updateGroupMemberStatus db userId membership GSMemAccepted
|
||||||
updateCIGroupInvitationStatus user
|
updateCIGroupInvitationStatus user
|
||||||
@ -2850,7 +2850,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
processDirectMessage :: ACommand 'Agent e -> ConnectionEntity -> Connection -> Maybe Contact -> m ()
|
processDirectMessage :: ACommand 'Agent e -> ConnectionEntity -> Connection -> Maybe Contact -> m ()
|
||||||
processDirectMessage agentMsg connEntity conn@Connection {connId, connChatVRange, viaUserContactLink, groupLinkId, customUserProfileId, connectionCode} = \case
|
processDirectMessage agentMsg connEntity conn@Connection {connId, peerChatVRange, viaUserContactLink, groupLinkId, customUserProfileId, connectionCode} = \case
|
||||||
Nothing -> case agentMsg of
|
Nothing -> case agentMsg of
|
||||||
CONF confId _ connInfo -> do
|
CONF confId _ connInfo -> do
|
||||||
-- [incognito] send saved profile
|
-- [incognito] send saved profile
|
||||||
@ -2931,7 +2931,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
CONF confId _ connInfo -> do
|
CONF confId _ connInfo -> do
|
||||||
-- confirming direct connection with a member
|
-- confirming direct connection with a member
|
||||||
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
||||||
conn' <- updateConnChatVRange conn chatVRange
|
conn' <- updatePeerChatVRange conn chatVRange
|
||||||
case chatMsgEvent of
|
case chatMsgEvent of
|
||||||
XGrpMemInfo _memId _memProfile -> do
|
XGrpMemInfo _memId _memProfile -> do
|
||||||
-- TODO check member ID
|
-- TODO check member ID
|
||||||
@ -2941,7 +2941,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
_ -> messageError "CONF from member must have x.grp.mem.info"
|
_ -> messageError "CONF from member must have x.grp.mem.info"
|
||||||
INFO connInfo -> do
|
INFO connInfo -> do
|
||||||
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
||||||
_conn' <- updateConnChatVRange conn chatVRange
|
_conn' <- updatePeerChatVRange conn chatVRange
|
||||||
case chatMsgEvent of
|
case chatMsgEvent of
|
||||||
XGrpMemInfo _memId _memProfile -> do
|
XGrpMemInfo _memId _memProfile -> do
|
||||||
-- TODO check member ID
|
-- TODO check member ID
|
||||||
@ -2973,7 +2973,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
forM_ groupId_ $ \groupId -> do
|
forM_ groupId_ $ \groupId -> do
|
||||||
gVar <- asks idsDrg
|
gVar <- asks idsDrg
|
||||||
groupConnIds <- createAgentConnectionAsync user CFCreateConnGrpInv True SCMInvitation
|
groupConnIds <- createAgentConnectionAsync user CFCreateConnGrpInv True SCMInvitation
|
||||||
withStore $ \db -> createNewContactMemberAsync db gVar user groupId ct gLinkMemRole groupConnIds connChatVRange
|
withStore $ \db -> createNewContactMemberAsync db gVar user groupId ct gLinkMemRole groupConnIds peerChatVRange
|
||||||
_ -> pure ()
|
_ -> pure ()
|
||||||
Just (gInfo@GroupInfo {membership}, m@GroupMember {activeConn}) ->
|
Just (gInfo@GroupInfo {membership}, m@GroupMember {activeConn}) ->
|
||||||
when (maybe False ((== ConnReady) . connStatus) activeConn) $ do
|
when (maybe False ((== ConnReady) . connStatus) activeConn) $ do
|
||||||
@ -3042,7 +3042,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
-- [async agent commands] XGrpMemIntro continuation on receiving INV
|
-- [async agent commands] XGrpMemIntro continuation on receiving INV
|
||||||
CFCreateConnGrpMemInv ->
|
CFCreateConnGrpMemInv ->
|
||||||
ifM
|
ifM
|
||||||
(featureVersionSupported (connChatVRange conn) groupNoDirectVersion)
|
(featureVersionSupported (peerChatVRange conn) groupNoDirectVersion)
|
||||||
sendWithoutDirectCReq
|
sendWithoutDirectCReq
|
||||||
sendWithDirectCReq
|
sendWithDirectCReq
|
||||||
where
|
where
|
||||||
@ -3078,7 +3078,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
CRContactUri _ -> throwChatError $ CECommandError "unexpected ConnectionRequestUri type"
|
CRContactUri _ -> throwChatError $ CECommandError "unexpected ConnectionRequestUri type"
|
||||||
CONF confId _ connInfo -> do
|
CONF confId _ connInfo -> do
|
||||||
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
||||||
conn' <- updateConnChatVRange conn chatVRange
|
conn' <- updatePeerChatVRange conn chatVRange
|
||||||
case memberCategory m of
|
case memberCategory m of
|
||||||
GCInviteeMember ->
|
GCInviteeMember ->
|
||||||
case chatMsgEvent of
|
case chatMsgEvent of
|
||||||
@ -3100,7 +3100,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
_ -> messageError "CONF from member must have x.grp.mem.info"
|
_ -> messageError "CONF from member must have x.grp.mem.info"
|
||||||
INFO connInfo -> do
|
INFO connInfo -> do
|
||||||
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
||||||
_conn' <- updateConnChatVRange conn chatVRange
|
_conn' <- updatePeerChatVRange conn chatVRange
|
||||||
case chatMsgEvent of
|
case chatMsgEvent of
|
||||||
XGrpMemInfo memId _memProfile
|
XGrpMemInfo memId _memProfile
|
||||||
| sameMemberId memId m -> do
|
| sameMemberId memId m -> do
|
||||||
@ -3277,7 +3277,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
-- when recipient of the file "joins" connection created by the sender
|
-- when recipient of the file "joins" connection created by the sender
|
||||||
CONF confId _ connInfo -> do
|
CONF confId _ connInfo -> do
|
||||||
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
||||||
conn' <- updateConnChatVRange conn chatVRange
|
conn' <- updatePeerChatVRange conn chatVRange
|
||||||
case chatMsgEvent of
|
case chatMsgEvent of
|
||||||
-- TODO save XFileAcpt message
|
-- TODO save XFileAcpt message
|
||||||
XFileAcpt name
|
XFileAcpt name
|
||||||
@ -3346,7 +3346,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
-- (sender doesn't create connections for all group members)
|
-- (sender doesn't create connections for all group members)
|
||||||
CONF confId _ connInfo -> do
|
CONF confId _ connInfo -> do
|
||||||
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage conn connInfo
|
||||||
conn' <- updateConnChatVRange conn chatVRange
|
conn' <- updatePeerChatVRange conn chatVRange
|
||||||
case chatMsgEvent of
|
case chatMsgEvent of
|
||||||
XOk -> allowAgentConnectionAsync user conn' confId XOk -- [async agent commands] no continuation needed, but command should be asynchronous for stability
|
XOk -> allowAgentConnectionAsync user conn' confId XOk -- [async agent commands] no continuation needed, but command should be asynchronous for stability
|
||||||
_ -> pure ()
|
_ -> pure ()
|
||||||
@ -4042,7 +4042,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
|
|
||||||
processGroupInvitation :: Contact -> GroupInvitation -> RcvMessage -> MsgMeta -> m ()
|
processGroupInvitation :: Contact -> GroupInvitation -> RcvMessage -> MsgMeta -> m ()
|
||||||
processGroupInvitation ct inv msg msgMeta = do
|
processGroupInvitation ct inv msg msgMeta = do
|
||||||
let Contact {localDisplayName = c, activeConn = Connection {connChatVRange, customUserProfileId, groupLinkId = groupLinkId'}} = ct
|
let Contact {localDisplayName = c, activeConn = Connection {peerChatVRange, customUserProfileId, groupLinkId = groupLinkId'}} = ct
|
||||||
GroupInvitation {fromMember = (MemberIdRole fromMemId fromRole), invitedMember = (MemberIdRole memId memRole), connRequest, groupLinkId} = inv
|
GroupInvitation {fromMember = (MemberIdRole fromMemId fromRole), invitedMember = (MemberIdRole memId memRole), connRequest, groupLinkId} = inv
|
||||||
checkIntegrityCreateItem (CDDirectRcv ct) msgMeta
|
checkIntegrityCreateItem (CDDirectRcv ct) msgMeta
|
||||||
when (fromRole < GRAdmin || fromRole < memRole) $ throwChatError (CEGroupContactRole c)
|
when (fromRole < GRAdmin || fromRole < memRole) $ throwChatError (CEGroupContactRole c)
|
||||||
@ -4053,7 +4053,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
then do
|
then do
|
||||||
connIds <- joinAgentConnectionAsync user True connRequest =<< directMessage (XGrpAcpt memberId)
|
connIds <- joinAgentConnectionAsync user True connRequest =<< directMessage (XGrpAcpt memberId)
|
||||||
withStore' $ \db -> do
|
withStore' $ \db -> do
|
||||||
createMemberConnectionAsync db user hostId connIds connChatVRange
|
createMemberConnectionAsync db user hostId connIds peerChatVRange
|
||||||
updateGroupMemberStatusById db userId hostId GSMemAccepted
|
updateGroupMemberStatusById db userId hostId GSMemAccepted
|
||||||
updateGroupMemberStatus db userId membership GSMemAccepted
|
updateGroupMemberStatus db userId membership GSMemAccepted
|
||||||
toView $ CRUserAcceptedGroupSent user gInfo {membership = membership {memberStatus = GSMemAccepted}} (Just ct)
|
toView $ CRUserAcceptedGroupSent user gInfo {membership = membership {memberStatus = GSMemAccepted}} (Just ct)
|
||||||
@ -4256,7 +4256,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
saveConnInfo :: Connection -> ConnInfo -> m Connection
|
saveConnInfo :: Connection -> ConnInfo -> m Connection
|
||||||
saveConnInfo activeConn connInfo = do
|
saveConnInfo activeConn connInfo = do
|
||||||
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage activeConn connInfo
|
ChatMessage {chatVRange, chatMsgEvent} <- parseChatMessage activeConn connInfo
|
||||||
conn' <- updateConnChatVRange activeConn chatVRange
|
conn' <- updatePeerChatVRange activeConn chatVRange
|
||||||
case chatMsgEvent of
|
case chatMsgEvent of
|
||||||
XInfo p -> do
|
XInfo p -> do
|
||||||
ct <- withStore $ \db -> createDirectContact db user conn' p
|
ct <- withStore $ \db -> createDirectContact db user conn' p
|
||||||
@ -4481,11 +4481,11 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
|
|||||||
toView $ CRChatItemStatusUpdated user (AChatItem SCTGroup SMDSnd (GroupChat gInfo) chatItem)
|
toView $ CRChatItemStatusUpdated user (AChatItem SCTGroup SMDSnd (GroupChat gInfo) chatItem)
|
||||||
_ -> pure ()
|
_ -> pure ()
|
||||||
|
|
||||||
updateConnChatVRange :: ChatMonad m => Connection -> VersionRange -> m Connection
|
updatePeerChatVRange :: ChatMonad m => Connection -> VersionRange -> m Connection
|
||||||
updateConnChatVRange conn@Connection {connId, connChatVRange} msgChatVRange
|
updatePeerChatVRange conn@Connection {connId, peerChatVRange} msgChatVRange
|
||||||
| msgChatVRange /= connChatVRange = do
|
| msgChatVRange /= peerChatVRange = do
|
||||||
withStore' $ \db -> setConnChatVRange db connId msgChatVRange
|
withStore' $ \db -> setPeerChatVRange db connId msgChatVRange
|
||||||
pure conn {connChatVRange = msgChatVRange}
|
pure conn {peerChatVRange = msgChatVRange}
|
||||||
| otherwise = pure conn
|
| otherwise = pure conn
|
||||||
|
|
||||||
featureVersionSupported :: ChatMonad' m => VersionRange -> Version -> m Bool
|
featureVersionSupported :: ChatMonad' m => VersionRange -> Version -> m Bool
|
||||||
@ -4759,7 +4759,7 @@ sendPendingGroupMessages user GroupMember {groupMemberId, localDisplayName} conn
|
|||||||
saveRcvMSG :: ChatMonad m => Connection -> ConnOrGroupId -> MsgMeta -> MsgBody -> CommandId -> m (Connection, RcvMessage)
|
saveRcvMSG :: ChatMonad m => Connection -> ConnOrGroupId -> MsgMeta -> MsgBody -> CommandId -> m (Connection, RcvMessage)
|
||||||
saveRcvMSG conn@Connection {connId} connOrGroupId agentMsgMeta msgBody agentAckCmdId = do
|
saveRcvMSG conn@Connection {connId} connOrGroupId agentMsgMeta msgBody agentAckCmdId = do
|
||||||
ACMsg _ ChatMessage {chatVRange, msgId = sharedMsgId_, chatMsgEvent} <- parseAChatMessage conn agentMsgMeta msgBody
|
ACMsg _ ChatMessage {chatVRange, msgId = sharedMsgId_, chatMsgEvent} <- parseAChatMessage conn agentMsgMeta msgBody
|
||||||
conn' <- updateConnChatVRange conn chatVRange
|
conn' <- updatePeerChatVRange conn chatVRange
|
||||||
let agentMsgId = fst $ recipient agentMsgMeta
|
let agentMsgId = fst $ recipient agentMsgMeta
|
||||||
newMsg = NewMessage {chatMsgEvent, msgBody}
|
newMsg = NewMessage {chatMsgEvent, msgBody}
|
||||||
rcvMsgDelivery = RcvMsgDelivery {connId, agentMsgId, agentMsgMeta, agentAckCmdId}
|
rcvMsgDelivery = RcvMsgDelivery {connId, agentMsgId, agentMsgMeta, agentAckCmdId}
|
||||||
|
@ -8,19 +8,19 @@ import Database.SQLite.Simple.QQ (sql)
|
|||||||
m20230829_connections_chat_vrange :: Query
|
m20230829_connections_chat_vrange :: Query
|
||||||
m20230829_connections_chat_vrange =
|
m20230829_connections_chat_vrange =
|
||||||
[sql|
|
[sql|
|
||||||
ALTER TABLE connections ADD COLUMN chat_vrange_min_version INTEGER NOT NULL DEFAULT 1;
|
ALTER TABLE connections ADD COLUMN peer_chat_min_version INTEGER NOT NULL DEFAULT 1;
|
||||||
ALTER TABLE connections ADD COLUMN chat_vrange_max_version INTEGER NOT NULL DEFAULT 1;
|
ALTER TABLE connections ADD COLUMN peer_chat_max_version INTEGER NOT NULL DEFAULT 1;
|
||||||
|
|
||||||
ALTER TABLE contact_requests ADD COLUMN chat_vrange_min_version INTEGER NOT NULL DEFAULT 1;
|
ALTER TABLE contact_requests ADD COLUMN peer_chat_min_version INTEGER NOT NULL DEFAULT 1;
|
||||||
ALTER TABLE contact_requests ADD COLUMN chat_vrange_max_version INTEGER NOT NULL DEFAULT 1;
|
ALTER TABLE contact_requests ADD COLUMN peer_chat_max_version INTEGER NOT NULL DEFAULT 1;
|
||||||
|]
|
|]
|
||||||
|
|
||||||
down_m20230829_connections_chat_vrange :: Query
|
down_m20230829_connections_chat_vrange :: Query
|
||||||
down_m20230829_connections_chat_vrange =
|
down_m20230829_connections_chat_vrange =
|
||||||
[sql|
|
[sql|
|
||||||
ALTER TABLE contact_requests DROP COLUMN chat_vrange_max_version;
|
ALTER TABLE contact_requests DROP COLUMN peer_chat_max_version;
|
||||||
ALTER TABLE contact_requests DROP COLUMN chat_vrange_min_version;
|
ALTER TABLE contact_requests DROP COLUMN peer_chat_min_version;
|
||||||
|
|
||||||
ALTER TABLE connections DROP COLUMN chat_vrange_max_version;
|
ALTER TABLE connections DROP COLUMN peer_chat_max_version;
|
||||||
ALTER TABLE connections DROP COLUMN chat_vrange_min_version;
|
ALTER TABLE connections DROP COLUMN peer_chat_min_version;
|
||||||
|]
|
|]
|
||||||
|
@ -285,8 +285,8 @@ CREATE TABLE connections(
|
|||||||
security_code TEXT NULL,
|
security_code TEXT NULL,
|
||||||
security_code_verified_at TEXT NULL,
|
security_code_verified_at TEXT NULL,
|
||||||
auth_err_counter INTEGER DEFAULT 0 CHECK(auth_err_counter NOT NULL),
|
auth_err_counter INTEGER DEFAULT 0 CHECK(auth_err_counter NOT NULL),
|
||||||
chat_vrange_min_version INTEGER NOT NULL DEFAULT 1,
|
peer_chat_min_version INTEGER NOT NULL DEFAULT 1,
|
||||||
chat_vrange_max_version INTEGER NOT NULL DEFAULT 1,
|
peer_chat_max_version INTEGER NOT NULL DEFAULT 1,
|
||||||
FOREIGN KEY(snd_file_id, connection_id)
|
FOREIGN KEY(snd_file_id, connection_id)
|
||||||
REFERENCES snd_files(file_id, connection_id)
|
REFERENCES snd_files(file_id, connection_id)
|
||||||
ON DELETE CASCADE
|
ON DELETE CASCADE
|
||||||
@ -320,8 +320,8 @@ CREATE TABLE contact_requests(
|
|||||||
user_id INTEGER NOT NULL REFERENCES users ON DELETE CASCADE,
|
user_id INTEGER NOT NULL REFERENCES users ON DELETE CASCADE,
|
||||||
updated_at TEXT CHECK(updated_at NOT NULL),
|
updated_at TEXT CHECK(updated_at NOT NULL),
|
||||||
xcontact_id BLOB,
|
xcontact_id BLOB,
|
||||||
chat_vrange_min_version INTEGER NOT NULL DEFAULT 1,
|
peer_chat_min_version INTEGER NOT NULL DEFAULT 1,
|
||||||
chat_vrange_max_version INTEGER NOT NULL DEFAULT 1,
|
peer_chat_max_version INTEGER NOT NULL DEFAULT 1,
|
||||||
FOREIGN KEY(user_id, local_display_name)
|
FOREIGN KEY(user_id, local_display_name)
|
||||||
REFERENCES display_names(user_id, local_display_name)
|
REFERENCES display_names(user_id, local_display_name)
|
||||||
ON UPDATE CASCADE
|
ON UPDATE CASCADE
|
||||||
|
@ -50,7 +50,7 @@ getConnectionEntity db user@User {userId, userContactId} agentConnId = do
|
|||||||
[sql|
|
[sql|
|
||||||
SELECT connection_id, agent_conn_id, conn_level, via_contact, via_user_contact_link, via_group_link, group_link_id, custom_user_profile_id,
|
SELECT connection_id, agent_conn_id, conn_level, via_contact, via_user_contact_link, via_group_link, group_link_id, custom_user_profile_id,
|
||||||
conn_status, conn_type, local_alias, contact_id, group_member_id, snd_file_id, rcv_file_id, user_contact_link_id, created_at, security_code, security_code_verified_at, auth_err_counter,
|
conn_status, conn_type, local_alias, contact_id, group_member_id, snd_file_id, rcv_file_id, user_contact_link_id, created_at, security_code, security_code_verified_at, auth_err_counter,
|
||||||
chat_vrange_min_version, chat_vrange_max_version
|
peer_chat_min_version, peer_chat_max_version
|
||||||
FROM connections
|
FROM connections
|
||||||
WHERE user_id = ? AND agent_conn_id = ?
|
WHERE user_id = ? AND agent_conn_id = ?
|
||||||
|]
|
|]
|
||||||
|
@ -145,7 +145,7 @@ getConnReqContactXContactId db user@User {userId} cReqHash = do
|
|||||||
-- Connection
|
-- Connection
|
||||||
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
||||||
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM contacts ct
|
FROM contacts ct
|
||||||
JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id
|
JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id
|
||||||
JOIN connections c ON c.contact_id = ct.contact_id
|
JOIN connections c ON c.contact_id = ct.contact_id
|
||||||
@ -443,7 +443,7 @@ createOrUpdateContactRequest db user@User {userId} userContactLinkId invId (Vers
|
|||||||
db
|
db
|
||||||
[sql|
|
[sql|
|
||||||
INSERT INTO contact_requests
|
INSERT INTO contact_requests
|
||||||
(user_contact_link_id, agent_invitation_id, chat_vrange_min_version, chat_vrange_max_version, contact_profile_id, local_display_name, user_id, created_at, updated_at, xcontact_id)
|
(user_contact_link_id, agent_invitation_id, peer_chat_min_version, peer_chat_max_version, contact_profile_id, local_display_name, user_id, created_at, updated_at, xcontact_id)
|
||||||
VALUES (?,?,?,?,?,?,?,?,?,?)
|
VALUES (?,?,?,?,?,?,?,?,?,?)
|
||||||
|]
|
|]
|
||||||
(userContactLinkId, invId, minV, maxV, profileId, ldn, userId, currentTs, currentTs, xContactId_)
|
(userContactLinkId, invId, minV, maxV, profileId, ldn, userId, currentTs, currentTs, xContactId_)
|
||||||
@ -461,7 +461,7 @@ createOrUpdateContactRequest db user@User {userId} userContactLinkId invId (Vers
|
|||||||
-- Connection
|
-- Connection
|
||||||
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
||||||
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM contacts ct
|
FROM contacts ct
|
||||||
JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id
|
JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id
|
||||||
LEFT JOIN connections c ON c.contact_id = ct.contact_id
|
LEFT JOIN connections c ON c.contact_id = ct.contact_id
|
||||||
@ -479,7 +479,7 @@ createOrUpdateContactRequest db user@User {userId} userContactLinkId invId (Vers
|
|||||||
SELECT
|
SELECT
|
||||||
cr.contact_request_id, cr.local_display_name, cr.agent_invitation_id, cr.user_contact_link_id,
|
cr.contact_request_id, cr.local_display_name, cr.agent_invitation_id, cr.user_contact_link_id,
|
||||||
c.agent_conn_id, cr.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, cr.xcontact_id, p.preferences, cr.created_at, cr.updated_at,
|
c.agent_conn_id, cr.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, cr.xcontact_id, p.preferences, cr.created_at, cr.updated_at,
|
||||||
cr.chat_vrange_min_version, cr.chat_vrange_max_version
|
cr.peer_chat_min_version, cr.peer_chat_max_version
|
||||||
FROM contact_requests cr
|
FROM contact_requests cr
|
||||||
JOIN connections c USING (user_contact_link_id)
|
JOIN connections c USING (user_contact_link_id)
|
||||||
JOIN contact_profiles p USING (contact_profile_id)
|
JOIN contact_profiles p USING (contact_profile_id)
|
||||||
@ -499,7 +499,7 @@ createOrUpdateContactRequest db user@User {userId} userContactLinkId invId (Vers
|
|||||||
db
|
db
|
||||||
[sql|
|
[sql|
|
||||||
UPDATE contact_requests
|
UPDATE contact_requests
|
||||||
SET agent_invitation_id = ?, chat_vrange_min_version = ?, chat_vrange_max_version = ?, updated_at = ?
|
SET agent_invitation_id = ?, peer_chat_min_version = ?, peer_chat_max_version = ?, updated_at = ?
|
||||||
WHERE user_id = ? AND contact_request_id = ?
|
WHERE user_id = ? AND contact_request_id = ?
|
||||||
|]
|
|]
|
||||||
(invId, minV, maxV, currentTs, userId, cReqId)
|
(invId, minV, maxV, currentTs, userId, cReqId)
|
||||||
@ -509,7 +509,7 @@ createOrUpdateContactRequest db user@User {userId} userContactLinkId invId (Vers
|
|||||||
db
|
db
|
||||||
[sql|
|
[sql|
|
||||||
UPDATE contact_requests
|
UPDATE contact_requests
|
||||||
SET agent_invitation_id = ?, chat_vrange_min_version = ?, chat_vrange_max_version = ?, local_display_name = ?, updated_at = ?
|
SET agent_invitation_id = ?, peer_chat_min_version = ?, peer_chat_max_version = ?, local_display_name = ?, updated_at = ?
|
||||||
WHERE user_id = ? AND contact_request_id = ?
|
WHERE user_id = ? AND contact_request_id = ?
|
||||||
|]
|
|]
|
||||||
(invId, minV, maxV, ldn, currentTs, userId, cReqId)
|
(invId, minV, maxV, ldn, currentTs, userId, cReqId)
|
||||||
@ -548,7 +548,7 @@ getContactRequest db User {userId} contactRequestId =
|
|||||||
SELECT
|
SELECT
|
||||||
cr.contact_request_id, cr.local_display_name, cr.agent_invitation_id, cr.user_contact_link_id,
|
cr.contact_request_id, cr.local_display_name, cr.agent_invitation_id, cr.user_contact_link_id,
|
||||||
c.agent_conn_id, cr.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, cr.xcontact_id, p.preferences, cr.created_at, cr.updated_at,
|
c.agent_conn_id, cr.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, cr.xcontact_id, p.preferences, cr.created_at, cr.updated_at,
|
||||||
cr.chat_vrange_min_version, cr.chat_vrange_max_version
|
cr.peer_chat_min_version, cr.peer_chat_max_version
|
||||||
FROM contact_requests cr
|
FROM contact_requests cr
|
||||||
JOIN connections c USING (user_contact_link_id)
|
JOIN connections c USING (user_contact_link_id)
|
||||||
JOIN contact_profiles p USING (contact_profile_id)
|
JOIN contact_profiles p USING (contact_profile_id)
|
||||||
@ -625,7 +625,7 @@ getContact_ db user@User {userId} contactId deleted =
|
|||||||
-- Connection
|
-- Connection
|
||||||
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
||||||
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM contacts ct
|
FROM contacts ct
|
||||||
JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id
|
JOIN contact_profiles cp ON ct.contact_profile_id = cp.contact_profile_id
|
||||||
LEFT JOIN connections c ON c.contact_id = ct.contact_id
|
LEFT JOIN connections c ON c.contact_id = ct.contact_id
|
||||||
@ -674,7 +674,7 @@ getContactConnections db userId Contact {contactId} =
|
|||||||
[sql|
|
[sql|
|
||||||
SELECT c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
SELECT c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
||||||
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM connections c
|
FROM connections c
|
||||||
JOIN contacts ct ON ct.contact_id = c.contact_id
|
JOIN contacts ct ON ct.contact_id = c.contact_id
|
||||||
WHERE c.user_id = ? AND ct.user_id = ? AND ct.contact_id = ?
|
WHERE c.user_id = ? AND ct.user_id = ? AND ct.contact_id = ?
|
||||||
@ -691,7 +691,7 @@ getConnectionById db User {userId} connId = ExceptT $ do
|
|||||||
[sql|
|
[sql|
|
||||||
SELECT connection_id, agent_conn_id, conn_level, via_contact, via_user_contact_link, via_group_link, group_link_id, custom_user_profile_id,
|
SELECT connection_id, agent_conn_id, conn_level, via_contact, via_user_contact_link, via_group_link, group_link_id, custom_user_profile_id,
|
||||||
conn_status, conn_type, local_alias, contact_id, group_member_id, snd_file_id, rcv_file_id, user_contact_link_id, created_at, security_code, security_code_verified_at, auth_err_counter,
|
conn_status, conn_type, local_alias, contact_id, group_member_id, snd_file_id, rcv_file_id, user_contact_link_id, created_at, security_code, security_code_verified_at, auth_err_counter,
|
||||||
chat_vrange_min_version, chat_vrange_max_version
|
peer_chat_min_version, peer_chat_max_version
|
||||||
FROM connections
|
FROM connections
|
||||||
WHERE user_id = ? AND connection_id = ?
|
WHERE user_id = ? AND connection_id = ?
|
||||||
|]
|
|]
|
||||||
|
@ -154,7 +154,7 @@ getGroupLinkConnection db User {userId} groupInfo@GroupInfo {groupId} =
|
|||||||
[sql|
|
[sql|
|
||||||
SELECT c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
SELECT c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
||||||
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM connections c
|
FROM connections c
|
||||||
JOIN user_contact_links uc ON c.user_contact_link_id = uc.user_contact_link_id
|
JOIN user_contact_links uc ON c.user_contact_link_id = uc.user_contact_link_id
|
||||||
WHERE c.user_id = ? AND uc.user_id = ? AND uc.group_id = ?
|
WHERE c.user_id = ? AND uc.user_id = ? AND uc.group_id = ?
|
||||||
@ -236,7 +236,7 @@ getGroupAndMember db User {userId, userContactId} groupMemberId =
|
|||||||
m.invited_by, m.local_display_name, m.contact_id, m.contact_profile_id, p.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, p.local_alias, p.preferences,
|
m.invited_by, m.local_display_name, m.contact_id, m.contact_profile_id, p.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, p.local_alias, p.preferences,
|
||||||
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
||||||
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM group_members m
|
FROM group_members m
|
||||||
JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id)
|
JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id)
|
||||||
JOIN groups g ON g.group_id = m.group_id
|
JOIN groups g ON g.group_id = m.group_id
|
||||||
@ -530,7 +530,7 @@ groupMemberQuery =
|
|||||||
m.invited_by, m.local_display_name, m.contact_id, m.contact_profile_id, p.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, p.local_alias, p.preferences,
|
m.invited_by, m.local_display_name, m.contact_id, m.contact_profile_id, p.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, p.local_alias, p.preferences,
|
||||||
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
||||||
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM group_members m
|
FROM group_members m
|
||||||
JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id)
|
JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id)
|
||||||
LEFT JOIN connections c ON c.connection_id = (
|
LEFT JOIN connections c ON c.connection_id = (
|
||||||
@ -615,11 +615,11 @@ getGroupInvitation db user groupId =
|
|||||||
DB.query db "SELECT g.inv_queue_info FROM groups g WHERE g.group_id = ? AND g.user_id = ?" (groupId, userId)
|
DB.query db "SELECT g.inv_queue_info FROM groups g WHERE g.group_id = ? AND g.user_id = ?" (groupId, userId)
|
||||||
|
|
||||||
createNewContactMember :: DB.Connection -> TVar ChaChaDRG -> User -> GroupId -> Contact -> GroupMemberRole -> ConnId -> ConnReqInvitation -> ExceptT StoreError IO GroupMember
|
createNewContactMember :: DB.Connection -> TVar ChaChaDRG -> User -> GroupId -> Contact -> GroupMemberRole -> ConnId -> ConnReqInvitation -> ExceptT StoreError IO GroupMember
|
||||||
createNewContactMember db gVar User {userId, userContactId} groupId Contact {contactId, localDisplayName, profile, activeConn = Connection {connChatVRange}} memberRole agentConnId connRequest =
|
createNewContactMember db gVar User {userId, userContactId} groupId Contact {contactId, localDisplayName, profile, activeConn = Connection {peerChatVRange}} memberRole agentConnId connRequest =
|
||||||
createWithRandomId gVar $ \memId -> do
|
createWithRandomId gVar $ \memId -> do
|
||||||
createdAt <- liftIO getCurrentTime
|
createdAt <- liftIO getCurrentTime
|
||||||
member@GroupMember {groupMemberId} <- createMember_ (MemberId memId) createdAt
|
member@GroupMember {groupMemberId} <- createMember_ (MemberId memId) createdAt
|
||||||
void $ createMemberConnection_ db userId groupMemberId agentConnId connChatVRange Nothing 0 createdAt
|
void $ createMemberConnection_ db userId groupMemberId agentConnId peerChatVRange Nothing 0 createdAt
|
||||||
pure member
|
pure member
|
||||||
where
|
where
|
||||||
createMember_ memberId createdAt = do
|
createMember_ memberId createdAt = do
|
||||||
@ -655,12 +655,12 @@ createNewContactMember db gVar User {userId, userContactId} groupId Contact {con
|
|||||||
)
|
)
|
||||||
|
|
||||||
createNewContactMemberAsync :: DB.Connection -> TVar ChaChaDRG -> User -> GroupId -> Contact -> GroupMemberRole -> (CommandId, ConnId) -> VersionRange -> ExceptT StoreError IO ()
|
createNewContactMemberAsync :: DB.Connection -> TVar ChaChaDRG -> User -> GroupId -> Contact -> GroupMemberRole -> (CommandId, ConnId) -> VersionRange -> ExceptT StoreError IO ()
|
||||||
createNewContactMemberAsync db gVar user@User {userId, userContactId} groupId Contact {contactId, localDisplayName, profile} memberRole (cmdId, agentConnId) connChatVRange =
|
createNewContactMemberAsync db gVar user@User {userId, userContactId} groupId Contact {contactId, localDisplayName, profile} memberRole (cmdId, agentConnId) peerChatVRange =
|
||||||
createWithRandomId gVar $ \memId -> do
|
createWithRandomId gVar $ \memId -> do
|
||||||
createdAt <- liftIO getCurrentTime
|
createdAt <- liftIO getCurrentTime
|
||||||
insertMember_ (MemberId memId) createdAt
|
insertMember_ (MemberId memId) createdAt
|
||||||
groupMemberId <- liftIO $ insertedRowId db
|
groupMemberId <- liftIO $ insertedRowId db
|
||||||
Connection {connId} <- createMemberConnection_ db userId groupMemberId agentConnId connChatVRange Nothing 0 createdAt
|
Connection {connId} <- createMemberConnection_ db userId groupMemberId agentConnId peerChatVRange Nothing 0 createdAt
|
||||||
setCommandConnId db user cmdId connId
|
setCommandConnId db user cmdId connId
|
||||||
where
|
where
|
||||||
insertMember_ memberId createdAt =
|
insertMember_ memberId createdAt =
|
||||||
@ -690,7 +690,7 @@ getContactViaMember db user@User {userId} GroupMember {groupMemberId} =
|
|||||||
-- Connection
|
-- Connection
|
||||||
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
||||||
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM contacts ct
|
FROM contacts ct
|
||||||
JOIN contact_profiles cp ON cp.contact_profile_id = ct.contact_profile_id
|
JOIN contact_profiles cp ON cp.contact_profile_id = ct.contact_profile_id
|
||||||
JOIN connections c ON c.connection_id = (
|
JOIN connections c ON c.connection_id = (
|
||||||
@ -714,14 +714,14 @@ getMemberInvitation db User {userId} groupMemberId =
|
|||||||
DB.query db "SELECT sent_inv_queue_info FROM group_members WHERE group_member_id = ? AND user_id = ?" (groupMemberId, userId)
|
DB.query db "SELECT sent_inv_queue_info FROM group_members WHERE group_member_id = ? AND user_id = ?" (groupMemberId, userId)
|
||||||
|
|
||||||
createMemberConnection :: DB.Connection -> UserId -> GroupMember -> ConnId -> VersionRange -> IO ()
|
createMemberConnection :: DB.Connection -> UserId -> GroupMember -> ConnId -> VersionRange -> IO ()
|
||||||
createMemberConnection db userId GroupMember {groupMemberId} agentConnId connChatVRange = do
|
createMemberConnection db userId GroupMember {groupMemberId} agentConnId peerChatVRange = do
|
||||||
currentTs <- getCurrentTime
|
currentTs <- getCurrentTime
|
||||||
void $ createMemberConnection_ db userId groupMemberId agentConnId connChatVRange Nothing 0 currentTs
|
void $ createMemberConnection_ db userId groupMemberId agentConnId peerChatVRange Nothing 0 currentTs
|
||||||
|
|
||||||
createMemberConnectionAsync :: DB.Connection -> User -> GroupMemberId -> (CommandId, ConnId) -> VersionRange -> IO ()
|
createMemberConnectionAsync :: DB.Connection -> User -> GroupMemberId -> (CommandId, ConnId) -> VersionRange -> IO ()
|
||||||
createMemberConnectionAsync db user@User {userId} groupMemberId (cmdId, agentConnId) connChatVRange = do
|
createMemberConnectionAsync db user@User {userId} groupMemberId (cmdId, agentConnId) peerChatVRange = do
|
||||||
currentTs <- getCurrentTime
|
currentTs <- getCurrentTime
|
||||||
Connection {connId} <- createMemberConnection_ db userId groupMemberId agentConnId connChatVRange Nothing 0 currentTs
|
Connection {connId} <- createMemberConnection_ db userId groupMemberId agentConnId peerChatVRange Nothing 0 currentTs
|
||||||
setCommandConnId db user cmdId connId
|
setCommandConnId db user cmdId connId
|
||||||
|
|
||||||
updateGroupMemberStatus :: DB.Connection -> UserId -> GroupMember -> GroupMemberStatus -> IO ()
|
updateGroupMemberStatus :: DB.Connection -> UserId -> GroupMember -> GroupMemberStatus -> IO ()
|
||||||
@ -978,7 +978,7 @@ createIntroToMemberContact db user@User {userId} GroupMember {memberContactId =
|
|||||||
[":contact_id" := contactId, ":updated_at" := ts, ":group_member_id" := groupMemberId]
|
[":contact_id" := contactId, ":updated_at" := ts, ":group_member_id" := groupMemberId]
|
||||||
|
|
||||||
createMemberConnection_ :: DB.Connection -> UserId -> Int64 -> ConnId -> VersionRange -> Maybe Int64 -> Int -> UTCTime -> IO Connection
|
createMemberConnection_ :: DB.Connection -> UserId -> Int64 -> ConnId -> VersionRange -> Maybe Int64 -> Int -> UTCTime -> IO Connection
|
||||||
createMemberConnection_ db userId groupMemberId agentConnId connChatVRange viaContact = createConnection_ db userId ConnMember (Just groupMemberId) agentConnId connChatVRange viaContact Nothing Nothing
|
createMemberConnection_ db userId groupMemberId agentConnId peerChatVRange viaContact = createConnection_ db userId ConnMember (Just groupMemberId) agentConnId peerChatVRange viaContact Nothing Nothing
|
||||||
|
|
||||||
getViaGroupMember :: DB.Connection -> User -> Contact -> IO (Maybe (GroupInfo, GroupMember))
|
getViaGroupMember :: DB.Connection -> User -> Contact -> IO (Maybe (GroupInfo, GroupMember))
|
||||||
getViaGroupMember db User {userId, userContactId} Contact {contactId} =
|
getViaGroupMember db User {userId, userContactId} Contact {contactId} =
|
||||||
@ -999,7 +999,7 @@ getViaGroupMember db User {userId, userContactId} Contact {contactId} =
|
|||||||
m.invited_by, m.local_display_name, m.contact_id, m.contact_profile_id, p.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, p.local_alias, p.preferences,
|
m.invited_by, m.local_display_name, m.contact_id, m.contact_profile_id, p.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, p.local_alias, p.preferences,
|
||||||
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
||||||
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM group_members m
|
FROM group_members m
|
||||||
JOIN contacts ct ON ct.contact_id = m.contact_id
|
JOIN contacts ct ON ct.contact_id = m.contact_id
|
||||||
JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id)
|
JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id)
|
||||||
@ -1033,7 +1033,7 @@ getViaGroupContact db user@User {userId} GroupMember {groupMemberId} =
|
|||||||
p.preferences, ct.user_preferences, ct.created_at, ct.updated_at, ct.chat_ts,
|
p.preferences, ct.user_preferences, ct.created_at, ct.updated_at, ct.chat_ts,
|
||||||
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
||||||
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM contacts ct
|
FROM contacts ct
|
||||||
JOIN contact_profiles p ON ct.contact_profile_id = p.contact_profile_id
|
JOIN contact_profiles p ON ct.contact_profile_id = p.contact_profile_id
|
||||||
JOIN connections c ON c.connection_id = (
|
JOIN connections c ON c.connection_id = (
|
||||||
|
@ -479,7 +479,7 @@ getDirectChatPreviews_ db user@User {userId} = do
|
|||||||
-- Connection
|
-- Connection
|
||||||
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id, c.conn_status, c.conn_type, c.local_alias,
|
||||||
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version,
|
c.peer_chat_min_version, c.peer_chat_max_version,
|
||||||
-- ChatStats
|
-- ChatStats
|
||||||
COALESCE(ChatStats.UnreadCount, 0), COALESCE(ChatStats.MinUnread, 0), ct.unread_chat,
|
COALESCE(ChatStats.UnreadCount, 0), COALESCE(ChatStats.MinUnread, 0), ct.unread_chat,
|
||||||
-- ChatItem
|
-- ChatItem
|
||||||
@ -611,7 +611,7 @@ getContactRequestChatPreviews_ db User {userId} =
|
|||||||
SELECT
|
SELECT
|
||||||
cr.contact_request_id, cr.local_display_name, cr.agent_invitation_id, cr.user_contact_link_id,
|
cr.contact_request_id, cr.local_display_name, cr.agent_invitation_id, cr.user_contact_link_id,
|
||||||
c.agent_conn_id, cr.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, cr.xcontact_id, p.preferences, cr.created_at, cr.updated_at,
|
c.agent_conn_id, cr.contact_profile_id, p.display_name, p.full_name, p.image, p.contact_link, cr.xcontact_id, p.preferences, cr.created_at, cr.updated_at,
|
||||||
cr.chat_vrange_min_version, cr.chat_vrange_max_version
|
cr.peer_chat_min_version, cr.peer_chat_max_version
|
||||||
FROM contact_requests cr
|
FROM contact_requests cr
|
||||||
JOIN connections c ON c.user_contact_link_id = cr.user_contact_link_id
|
JOIN connections c ON c.user_contact_link_id = cr.user_contact_link_id
|
||||||
JOIN contact_profiles p ON p.contact_profile_id = cr.contact_profile_id
|
JOIN contact_profiles p ON p.contact_profile_id = cr.contact_profile_id
|
||||||
|
@ -317,7 +317,7 @@ getUserAddressConnections db User {userId} = do
|
|||||||
[sql|
|
[sql|
|
||||||
SELECT c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
SELECT c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
||||||
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version
|
c.peer_chat_min_version, c.peer_chat_max_version
|
||||||
FROM connections c
|
FROM connections c
|
||||||
JOIN user_contact_links uc ON c.user_contact_link_id = uc.user_contact_link_id
|
JOIN user_contact_links uc ON c.user_contact_link_id = uc.user_contact_link_id
|
||||||
WHERE c.user_id = ? AND uc.user_id = ? AND uc.local_display_name = '' AND uc.group_id IS NULL
|
WHERE c.user_id = ? AND uc.user_id = ? AND uc.local_display_name = '' AND uc.group_id IS NULL
|
||||||
@ -332,7 +332,7 @@ getUserContactLinks db User {userId} =
|
|||||||
[sql|
|
[sql|
|
||||||
SELECT c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
SELECT c.connection_id, c.agent_conn_id, c.conn_level, c.via_contact, c.via_user_contact_link, c.via_group_link, c.group_link_id, c.custom_user_profile_id,
|
||||||
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
c.conn_status, c.conn_type, c.local_alias, c.contact_id, c.group_member_id, c.snd_file_id, c.rcv_file_id, c.user_contact_link_id, c.created_at, c.security_code, c.security_code_verified_at, c.auth_err_counter,
|
||||||
c.chat_vrange_min_version, c.chat_vrange_max_version,
|
c.peer_chat_min_version, c.peer_chat_max_version,
|
||||||
uc.user_contact_link_id, uc.conn_req_contact, uc.group_id
|
uc.user_contact_link_id, uc.conn_req_contact, uc.group_id
|
||||||
FROM connections c
|
FROM connections c
|
||||||
JOIN user_contact_links uc ON c.user_contact_link_id = uc.user_contact_link_id
|
JOIN user_contact_links uc ON c.user_contact_link_id = uc.user_contact_link_id
|
||||||
|
@ -143,8 +143,8 @@ toConnection :: ConnectionRow -> Connection
|
|||||||
toConnection ((connId, acId, connLevel, viaContact, viaUserContactLink, viaGroupLink, groupLinkId, customUserProfileId, connStatus, connType, localAlias) :. (contactId, groupMemberId, sndFileId, rcvFileId, userContactLinkId) :. (createdAt, code_, verifiedAt_, authErrCounter, minVer, maxVer)) =
|
toConnection ((connId, acId, connLevel, viaContact, viaUserContactLink, viaGroupLink, groupLinkId, customUserProfileId, connStatus, connType, localAlias) :. (contactId, groupMemberId, sndFileId, rcvFileId, userContactLinkId) :. (createdAt, code_, verifiedAt_, authErrCounter, minVer, maxVer)) =
|
||||||
let entityId = entityId_ connType
|
let entityId = entityId_ connType
|
||||||
connectionCode = SecurityCode <$> code_ <*> verifiedAt_
|
connectionCode = SecurityCode <$> code_ <*> verifiedAt_
|
||||||
connChatVRange = fromMaybe (versionToRange maxVer) $ safeVersionRange minVer maxVer
|
peerChatVRange = fromMaybe (versionToRange maxVer) $ safeVersionRange minVer maxVer
|
||||||
in Connection {connId, agentConnId = AgentConnId acId, connChatVRange, connLevel, viaContact, viaUserContactLink, viaGroupLink, groupLinkId, customUserProfileId, connStatus, connType, localAlias, entityId, connectionCode, authErrCounter, createdAt}
|
in Connection {connId, agentConnId = AgentConnId acId, peerChatVRange, connLevel, viaContact, viaUserContactLink, viaGroupLink, groupLinkId, customUserProfileId, connStatus, connType, localAlias, entityId, connectionCode, authErrCounter, createdAt}
|
||||||
where
|
where
|
||||||
entityId_ :: ConnType -> Maybe Int64
|
entityId_ :: ConnType -> Maybe Int64
|
||||||
entityId_ ConnContact = contactId
|
entityId_ ConnContact = contactId
|
||||||
@ -159,7 +159,7 @@ toMaybeConnection ((Just connId, Just agentConnId, Just connLevel, viaContact, v
|
|||||||
toMaybeConnection _ = Nothing
|
toMaybeConnection _ = Nothing
|
||||||
|
|
||||||
createConnection_ :: DB.Connection -> UserId -> ConnType -> Maybe Int64 -> ConnId -> VersionRange -> Maybe ContactId -> Maybe Int64 -> Maybe ProfileId -> Int -> UTCTime -> IO Connection
|
createConnection_ :: DB.Connection -> UserId -> ConnType -> Maybe Int64 -> ConnId -> VersionRange -> Maybe ContactId -> Maybe Int64 -> Maybe ProfileId -> Int -> UTCTime -> IO Connection
|
||||||
createConnection_ db userId connType entityId acId connChatVRange@(VersionRange minV maxV) viaContact viaUserContactLink customUserProfileId connLevel currentTs = do
|
createConnection_ db userId connType entityId acId peerChatVRange@(VersionRange minV maxV) viaContact viaUserContactLink customUserProfileId connLevel currentTs = do
|
||||||
viaLinkGroupId :: Maybe Int64 <- fmap join . forM viaUserContactLink $ \ucLinkId ->
|
viaLinkGroupId :: Maybe Int64 <- fmap join . forM viaUserContactLink $ \ucLinkId ->
|
||||||
maybeFirstRow fromOnly $ DB.query db "SELECT group_id FROM user_contact_links WHERE user_id = ? AND user_contact_link_id = ? AND group_id IS NOT NULL" (userId, ucLinkId)
|
maybeFirstRow fromOnly $ DB.query db "SELECT group_id FROM user_contact_links WHERE user_id = ? AND user_contact_link_id = ? AND group_id IS NOT NULL" (userId, ucLinkId)
|
||||||
let viaGroupLink = isJust viaLinkGroupId
|
let viaGroupLink = isJust viaLinkGroupId
|
||||||
@ -169,7 +169,7 @@ createConnection_ db userId connType entityId acId connChatVRange@(VersionRange
|
|||||||
INSERT INTO connections (
|
INSERT INTO connections (
|
||||||
user_id, agent_conn_id, conn_level, via_contact, via_user_contact_link, via_group_link, custom_user_profile_id, conn_status, conn_type,
|
user_id, agent_conn_id, conn_level, via_contact, via_user_contact_link, via_group_link, custom_user_profile_id, conn_status, conn_type,
|
||||||
contact_id, group_member_id, snd_file_id, rcv_file_id, user_contact_link_id, created_at, updated_at,
|
contact_id, group_member_id, snd_file_id, rcv_file_id, user_contact_link_id, created_at, updated_at,
|
||||||
chat_vrange_min_version, chat_vrange_max_version
|
peer_chat_min_version, peer_chat_max_version
|
||||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||||
|]
|
|]
|
||||||
( (userId, acId, connLevel, viaContact, viaUserContactLink, viaGroupLink, customUserProfileId, ConnNew, connType)
|
( (userId, acId, connLevel, viaContact, viaUserContactLink, viaGroupLink, customUserProfileId, ConnNew, connType)
|
||||||
@ -177,17 +177,17 @@ createConnection_ db userId connType entityId acId connChatVRange@(VersionRange
|
|||||||
:. (minV, maxV)
|
:. (minV, maxV)
|
||||||
)
|
)
|
||||||
connId <- insertedRowId db
|
connId <- insertedRowId db
|
||||||
pure Connection {connId, agentConnId = AgentConnId acId, connChatVRange, connType, entityId, viaContact, viaUserContactLink, viaGroupLink, groupLinkId = Nothing, customUserProfileId, connLevel, connStatus = ConnNew, localAlias = "", createdAt = currentTs, connectionCode = Nothing, authErrCounter = 0}
|
pure Connection {connId, agentConnId = AgentConnId acId, peerChatVRange, connType, entityId, viaContact, viaUserContactLink, viaGroupLink, groupLinkId = Nothing, customUserProfileId, connLevel, connStatus = ConnNew, localAlias = "", createdAt = currentTs, connectionCode = Nothing, authErrCounter = 0}
|
||||||
where
|
where
|
||||||
ent ct = if connType == ct then entityId else Nothing
|
ent ct = if connType == ct then entityId else Nothing
|
||||||
|
|
||||||
setConnChatVRange :: DB.Connection -> Int64 -> VersionRange -> IO ()
|
setPeerChatVRange :: DB.Connection -> Int64 -> VersionRange -> IO ()
|
||||||
setConnChatVRange db connId (VersionRange minVer maxVer) =
|
setPeerChatVRange db connId (VersionRange minVer maxVer) =
|
||||||
DB.execute
|
DB.execute
|
||||||
db
|
db
|
||||||
[sql|
|
[sql|
|
||||||
UPDATE connections
|
UPDATE connections
|
||||||
SET chat_vrange_min_version = ?, chat_vrange_max_version = ?
|
SET peer_chat_min_version = ?, peer_chat_max_version = ?
|
||||||
WHERE connection_id = ?
|
WHERE connection_id = ?
|
||||||
|]
|
|]
|
||||||
(minVer, maxVer, connId)
|
(minVer, maxVer, connId)
|
||||||
|
@ -564,7 +564,7 @@ memberInfo :: GroupMember -> MemberInfo
|
|||||||
memberInfo GroupMember {memberId, memberRole, memberProfile, activeConn} =
|
memberInfo GroupMember {memberId, memberRole, memberProfile, activeConn} =
|
||||||
MemberInfo memberId memberRole memberChatVRange (fromLocalProfile memberProfile)
|
MemberInfo memberId memberRole memberChatVRange (fromLocalProfile memberProfile)
|
||||||
where
|
where
|
||||||
memberChatVRange = ChatVersionRange . connChatVRange <$> activeConn
|
memberChatVRange = ChatVersionRange . peerChatVRange <$> activeConn
|
||||||
|
|
||||||
data ReceivedGroupInvitation = ReceivedGroupInvitation
|
data ReceivedGroupInvitation = ReceivedGroupInvitation
|
||||||
{ fromMember :: GroupMember,
|
{ fromMember :: GroupMember,
|
||||||
@ -1167,7 +1167,7 @@ type ConnReqContact = ConnectionRequestUri 'CMContact
|
|||||||
data Connection = Connection
|
data Connection = Connection
|
||||||
{ connId :: Int64,
|
{ connId :: Int64,
|
||||||
agentConnId :: AgentConnId,
|
agentConnId :: AgentConnId,
|
||||||
connChatVRange :: VersionRange,
|
peerChatVRange :: VersionRange,
|
||||||
connLevel :: Int,
|
connLevel :: Int,
|
||||||
viaContact :: Maybe Int64, -- group member contact ID, if not direct connection
|
viaContact :: Maybe Int64, -- group member contact ID, if not direct connection
|
||||||
viaUserContactLink :: Maybe Int64, -- user contact link ID, if connected via "user address"
|
viaUserContactLink :: Maybe Int64, -- user contact link ID, if connected via "user address"
|
||||||
|
@ -963,7 +963,7 @@ viewContactInfo ct@Contact {contactId, profile = LocalProfile {localAlias, conta
|
|||||||
incognitoProfile
|
incognitoProfile
|
||||||
<> ["alias: " <> plain localAlias | localAlias /= ""]
|
<> ["alias: " <> plain localAlias | localAlias /= ""]
|
||||||
<> [viewConnectionVerified (contactSecurityCode ct)]
|
<> [viewConnectionVerified (contactSecurityCode ct)]
|
||||||
<> [viewConnChatVRange (connChatVRange activeConn)]
|
<> [viewPeerChatVRange (peerChatVRange activeConn)]
|
||||||
|
|
||||||
viewGroupInfo :: GroupInfo -> GroupSummary -> [StyledString]
|
viewGroupInfo :: GroupInfo -> GroupSummary -> [StyledString]
|
||||||
viewGroupInfo GroupInfo {groupId} s =
|
viewGroupInfo GroupInfo {groupId} s =
|
||||||
@ -979,14 +979,14 @@ viewGroupMemberInfo GroupInfo {groupId} m@GroupMember {groupMemberId, memberProf
|
|||||||
<> maybe ["member not connected"] viewConnectionStats stats
|
<> maybe ["member not connected"] viewConnectionStats stats
|
||||||
<> ["alias: " <> plain localAlias | localAlias /= ""]
|
<> ["alias: " <> plain localAlias | localAlias /= ""]
|
||||||
<> [viewConnectionVerified (memberSecurityCode m) | isJust stats]
|
<> [viewConnectionVerified (memberSecurityCode m) | isJust stats]
|
||||||
<> maybe [] (\ac -> [viewConnChatVRange (connChatVRange ac)]) activeConn
|
<> maybe [] (\ac -> [viewPeerChatVRange (peerChatVRange ac)]) activeConn
|
||||||
|
|
||||||
viewConnectionVerified :: Maybe SecurityCode -> StyledString
|
viewConnectionVerified :: Maybe SecurityCode -> StyledString
|
||||||
viewConnectionVerified (Just _) = "connection verified" -- TODO show verification time?
|
viewConnectionVerified (Just _) = "connection verified" -- TODO show verification time?
|
||||||
viewConnectionVerified _ = "connection not verified, use " <> highlight' "/code" <> " command to see security code"
|
viewConnectionVerified _ = "connection not verified, use " <> highlight' "/code" <> " command to see security code"
|
||||||
|
|
||||||
viewConnChatVRange :: VersionRange -> StyledString
|
viewPeerChatVRange :: VersionRange -> StyledString
|
||||||
viewConnChatVRange (VersionRange minVer maxVer) = "chat protocol version range: (" <> sShow minVer <> ", " <> sShow maxVer <> ")"
|
viewPeerChatVRange (VersionRange minVer maxVer) = "peer chat protocol version range: (" <> sShow minVer <> ", " <> sShow maxVer <> ")"
|
||||||
|
|
||||||
viewConnectionStats :: ConnectionStats -> [StyledString]
|
viewConnectionStats :: ConnectionStats -> [StyledString]
|
||||||
viewConnectionStats ConnectionStats {rcvQueuesInfo, sndQueuesInfo} =
|
viewConnectionStats ConnectionStats {rcvQueuesInfo, sndQueuesInfo} =
|
||||||
|
@ -96,18 +96,18 @@ chatDirectTests = do
|
|||||||
describe "delivery receipts" $ do
|
describe "delivery receipts" $ do
|
||||||
it "should send delivery receipts" testSendDeliveryReceipts
|
it "should send delivery receipts" testSendDeliveryReceipts
|
||||||
it "should send delivery receipts depending on configuration" testConfigureDeliveryReceipts
|
it "should send delivery receipts depending on configuration" testConfigureDeliveryReceipts
|
||||||
describe "negotiate connection chat protocol version range" $ do
|
describe "negotiate connection peer chat protocol version range" $ do
|
||||||
describe "version range correctly set for new connection via invitation" $ do
|
describe "peer version range correctly set for new connection via invitation" $ do
|
||||||
testInvVRange supportedChatVRange supportedChatVRange
|
testInvVRange supportedChatVRange supportedChatVRange
|
||||||
testInvVRange supportedChatVRange vr11
|
testInvVRange supportedChatVRange vr11
|
||||||
testInvVRange vr11 supportedChatVRange
|
testInvVRange vr11 supportedChatVRange
|
||||||
testInvVRange vr11 vr11
|
testInvVRange vr11 vr11
|
||||||
describe "version range correctly set for new connection via contact request" $ do
|
describe "peer version range correctly set for new connection via contact request" $ do
|
||||||
testReqVRange supportedChatVRange supportedChatVRange
|
testReqVRange supportedChatVRange supportedChatVRange
|
||||||
testReqVRange supportedChatVRange vr11
|
testReqVRange supportedChatVRange vr11
|
||||||
testReqVRange vr11 supportedChatVRange
|
testReqVRange vr11 supportedChatVRange
|
||||||
testReqVRange vr11 vr11
|
testReqVRange vr11 vr11
|
||||||
it "update connection version range on received messages" testUpdateConnChatVRange
|
it "update peer version range on received messages" testUpdatePeerChatVRange
|
||||||
where
|
where
|
||||||
testInvVRange vr1 vr2 = it (vRangeStr vr1 <> " - " <> vRangeStr vr2) $ testConnInvChatVRange vr1 vr2
|
testInvVRange vr1 vr2 = it (vRangeStr vr1 <> " - " <> vRangeStr vr2) $ testConnInvChatVRange vr1 vr2
|
||||||
testReqVRange vr1 vr2 = it (vRangeStr vr1 <> " - " <> vRangeStr vr2) $ testConnReqChatVRange vr1 vr2
|
testReqVRange vr1 vr2 = it (vRangeStr vr1 <> " - " <> vRangeStr vr2) $ testConnReqChatVRange vr1 vr2
|
||||||
@ -2330,8 +2330,8 @@ testConnReqChatVRange ct1VRange ct2VRange tmp =
|
|||||||
bob ##> "/i alice"
|
bob ##> "/i alice"
|
||||||
contactInfoChatVRange bob ct1VRange
|
contactInfoChatVRange bob ct1VRange
|
||||||
|
|
||||||
testUpdateConnChatVRange :: HasCallStack => FilePath -> IO ()
|
testUpdatePeerChatVRange :: HasCallStack => FilePath -> IO ()
|
||||||
testUpdateConnChatVRange tmp =
|
testUpdatePeerChatVRange tmp =
|
||||||
withNewTestChat tmp "alice" aliceProfile $ \alice -> do
|
withNewTestChat tmp "alice" aliceProfile $ \alice -> do
|
||||||
withNewTestChatCfg tmp cfg11 "bob" bobProfile $ \bob -> do
|
withNewTestChatCfg tmp cfg11 "bob" bobProfile $ \bob -> do
|
||||||
connectUsers alice bob
|
connectUsers alice bob
|
||||||
@ -2378,4 +2378,4 @@ contactInfoChatVRange cc (VersionRange minVer maxVer) = do
|
|||||||
cc <## "sending messages via: localhost"
|
cc <## "sending messages via: localhost"
|
||||||
cc <## "you've shared main profile with this contact"
|
cc <## "you've shared main profile with this contact"
|
||||||
cc <## "connection not verified, use /code command to see security code"
|
cc <## "connection not verified, use /code command to see security code"
|
||||||
cc <## ("chat protocol version range: (" <> show minVer <> ", " <> show maxVer <> ")")
|
cc <## ("peer chat protocol version range: (" <> show minVer <> ", " <> show maxVer <> ")")
|
||||||
|
@ -528,7 +528,7 @@ startFileTransferWithDest' cc1 cc2 fileName fileSize fileDest_ = do
|
|||||||
|
|
||||||
currentChatVRangeInfo :: String
|
currentChatVRangeInfo :: String
|
||||||
currentChatVRangeInfo =
|
currentChatVRangeInfo =
|
||||||
"chat protocol version range: " <> vRangeStr supportedChatVRange
|
"peer chat protocol version range: " <> vRangeStr supportedChatVRange
|
||||||
|
|
||||||
vRangeStr :: VersionRange -> String
|
vRangeStr :: VersionRange -> String
|
||||||
vRangeStr (VersionRange minVer maxVer) = "(" <> show minVer <> ", " <> show maxVer <> ")"
|
vRangeStr (VersionRange minVer maxVer) = "(" <> show minVer <> ", " <> show maxVer <> ")"
|
||||||
|
Loading…
Reference in New Issue
Block a user