core: fix live file transfers queries (#1715)

This commit is contained in:
JRoberts
2023-01-10 16:22:21 +04:00
committed by GitHub
parent 5a7d61c964
commit 813fecddfe
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -1737,7 +1737,7 @@ subscribeUserConnections agentBatchSubscribe user = do
pendingConnSubsToView :: Map ConnId (Either AgentErrorType ()) -> Map ConnId PendingContactConnection -> m ()
pendingConnSubsToView rs = toView . CRPendingSubSummary . map (uncurry PendingSubStatus) . resultsFor rs
withStore_ :: (DB.Connection -> User -> IO [a]) -> m [a]
withStore_ a = withStore' (`a` user) `catchError` \_ -> pure []
withStore_ a = withStore' (`a` user) `catchError` \e -> toView (CRChatError e) >> pure []
filterErrors :: [(a, Maybe ChatError)] -> [(a, ChatError)]
filterErrors = mapMaybe (\(a, e_) -> (a,) <$> e_)
resultsFor :: Map ConnId (Either AgentErrorType ()) -> Map ConnId a -> [(a, Maybe ChatError)]
+2 -2
View File
@@ -1267,7 +1267,7 @@ getLiveSndFileTransfers db User {userId} = do
FROM files f
JOIN snd_files s USING (file_id)
WHERE f.user_id = ? AND s.file_status IN (?, ?, ?) AND s.file_inline IS NULL
AND created_at > ?
AND s.created_at > ?
|]
(userId, FSNew, FSAccepted, FSConnected, cutoffTs)
concatMap (filter liveTransfer) . rights <$> mapM (getSndFileTransfers_ db userId) fileIds
@@ -1287,7 +1287,7 @@ getLiveRcvFileTransfers db user@User {userId} = do
FROM files f
JOIN rcv_files r USING (file_id)
WHERE f.user_id = ? AND r.file_status IN (?, ?) AND r.rcv_file_inline IS NULL
AND created_at > ?
AND r.created_at > ?
|]
(userId, FSAccepted, FSConnected, cutoffTs)
rights <$> mapM (runExceptT . getRcvFileTransfer db user) fileIds