core: add connection id to ContactRef (#1798)

This commit is contained in:
JRoberts
2023-01-19 20:54:00 +04:00
committed by GitHub
parent ad6aa10cd2
commit cf4105e256
2 changed files with 6 additions and 2 deletions

View File

@@ -1721,11 +1721,11 @@ getConnectionsContacts db userId agentConnIds = do
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
conns <-
map (uncurry ContactRef)
map toContactRef
<$> DB.query
db
[sql|
SELECT ct.contact_id, ct.local_display_name
SELECT ct.contact_id, c.connection_id, ct.local_display_name
FROM contacts ct
JOIN connections c ON c.contact_id = ct.contact_id
WHERE ct.user_id = ?
@@ -1735,6 +1735,9 @@ getConnectionsContacts db userId agentConnIds = do
(userId, 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}
getGroupAndMember :: DB.Connection -> User -> Int64 -> ExceptT StoreError IO (GroupInfo, GroupMember)
getGroupAndMember db User {userId, userContactId} groupMemberId =

View File

@@ -172,6 +172,7 @@ contactSecurityCode Contact {activeConn} = connectionCode activeConn
data ContactRef = ContactRef
{ contactId :: ContactId,
connId :: Int64,
localDisplayName :: ContactName
}
deriving (Eq, Show, Generic)