mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-27 06:25:48 +00:00
test that light query results match the original
This commit is contained in:
+12
-1
@@ -3381,7 +3381,12 @@ subscribeUserConnections vr onlyNeeded user = do
|
||||
addSub :: Connection -> [ConnId] -> [ConnId]
|
||||
addSub c = (aConnId c :)
|
||||
getContactConns :: CM [ConnId]
|
||||
getContactConns = withStore_ getUserContactConnIds
|
||||
getContactConns = do
|
||||
ctConns <- withStore_ getUserContactConnIds
|
||||
ctConns' <- mapMaybe contactConnId . filter contactActive <$> withStore_ (`getUserContacts` vr)
|
||||
unless (S.fromList ctConns == S.fromList ctConns') $
|
||||
logError $ "getContactConns differ: " <> tshow (ctConns, ctConns')
|
||||
pure ctConns -- (map fst cts', M.fromList cts')
|
||||
getUserContactLinkConns :: CM ([ConnId], Map ConnId UserContact)
|
||||
getUserContactLinkConns = do
|
||||
(cs, ucs) <- unzip <$> withStore_ (`getUserContactLinks` vr)
|
||||
@@ -3390,6 +3395,12 @@ subscribeUserConnections vr onlyNeeded user = do
|
||||
getGroupMemberConns :: CM ([(GroupInfo, [ConnId])], [ConnId])
|
||||
getGroupMemberConns = do
|
||||
gs <- withStore_ (`getUserGroupMemberConnIds` vr)
|
||||
let mConns = S.fromList (concatMap snd gs)
|
||||
gs' <- withStore_ (`getUserGroups` vr)
|
||||
let mPairs = concatMap (\(Group _ ms) -> mapMaybe memberConnId (filter (not . memberRemoved) ms)) gs'
|
||||
let mConns' = S.fromList mPairs
|
||||
unless (mConns == mConns') $
|
||||
logError $ "getGroupMemberConns differ: " <> tshow (mConns, mConns')
|
||||
pure (gs, concatMap snd gs)
|
||||
getSndFileTransferConns :: CM ([ConnId], Map ConnId SndFileTransfer)
|
||||
getSndFileTransferConns = do
|
||||
|
||||
@@ -853,14 +853,28 @@ getUserContactConnIds :: DB.Connection -> User -> IO [ConnId]
|
||||
getUserContactConnIds db User {userId} =
|
||||
map fromOnly
|
||||
<$> DB.query
|
||||
db
|
||||
[sql|
|
||||
SELECT c.agent_conn_id
|
||||
FROM connections c
|
||||
JOIN contacts ct ON ct.contact_id = c.contact_id
|
||||
WHERE c.user_id = ? AND ct.user_id = ? AND ct.deleted = 0
|
||||
|]
|
||||
(userId, userId)
|
||||
db
|
||||
[sql|
|
||||
SELECT c.agent_conn_id
|
||||
FROM contacts ct
|
||||
LEFT JOIN connections c ON c.contact_id = ct.contact_id
|
||||
WHERE ct.user_id = ?
|
||||
AND ct.contact_status = ?
|
||||
AND ct.deleted = 0
|
||||
AND
|
||||
c.connection_id = (
|
||||
SELECT cc_connection_id FROM (
|
||||
SELECT
|
||||
cc.connection_id AS cc_connection_id,
|
||||
cc.created_at AS cc_created_at
|
||||
FROM connections cc
|
||||
WHERE cc.user_id = ct.user_id AND cc.contact_id = ct.contact_id
|
||||
ORDER BY cc_created_at DESC
|
||||
LIMIT 1
|
||||
)
|
||||
)
|
||||
|]
|
||||
(userId, CSActive)
|
||||
|
||||
getConnectionById :: DB.Connection -> VersionRangeChat -> User -> Int64 -> ExceptT StoreError IO Connection
|
||||
getConnectionById db vr User {userId} connId = ExceptT $ do
|
||||
|
||||
Reference in New Issue
Block a user