core: don't filter out non active user connections on UP & DOWN agent events; use agent connection id instead of db connection id for ContactRef (#1807)

This commit is contained in:
JRoberts
2023-01-20 15:02:27 +04:00
committed by GitHub
parent 396b3ae639
commit ef15dca0b4
5 changed files with 17 additions and 19 deletions
+7 -8
View File
@@ -1715,8 +1715,8 @@ getConnectionById db User {userId} connId = ExceptT $ do
|]
(userId, connId)
getConnectionsContacts :: DB.Connection -> UserId -> [ConnId] -> IO [ContactRef]
getConnectionsContacts db userId agentConnIds = do
getConnectionsContacts :: DB.Connection -> [ConnId] -> IO [ContactRef]
getConnectionsContacts db agentConnIds = do
DB.execute_ db "DROP TABLE IF EXISTS temp.conn_ids"
DB.execute_ db "CREATE TABLE temp.conn_ids (conn_id BLOB)"
DB.executeMany db "INSERT INTO temp.conn_ids (conn_id) VALUES (?)" $ map Only agentConnIds
@@ -1725,19 +1725,18 @@ getConnectionsContacts db userId agentConnIds = do
<$> DB.query
db
[sql|
SELECT ct.contact_id, c.connection_id, ct.local_display_name
SELECT ct.contact_id, c.connection_id, c.agent_conn_id, ct.local_display_name
FROM contacts ct
JOIN connections c ON c.contact_id = ct.contact_id
WHERE ct.user_id = ?
AND c.agent_conn_id IN (SELECT conn_id FROM temp.conn_ids)
WHERE c.agent_conn_id IN (SELECT conn_id FROM temp.conn_ids)
AND c.conn_type = ?
|]
(userId, ConnContact)
(Only ConnContact)
DB.execute_ db "DROP TABLE temp.conn_ids"
pure conns
where
toContactRef :: (ContactId, Int64, ContactName) -> ContactRef
toContactRef (contactId, connId, localDisplayName) = ContactRef {contactId, connId, localDisplayName}
toContactRef :: (ContactId, Int64, ConnId, ContactName) -> ContactRef
toContactRef (contactId, connId, acId, localDisplayName) = ContactRef {contactId, connId, agentConnId = AgentConnId acId, localDisplayName}
getGroupAndMember :: DB.Connection -> User -> Int64 -> ExceptT StoreError IO (GroupInfo, GroupMember)
getGroupAndMember db User {userId, userContactId} groupMemberId =