From 813fecddfe8d73e29f7365156b9c77837f618321 Mon Sep 17 00:00:00 2001 From: JRoberts <8711996+jr-simplex@users.noreply.github.com> Date: Tue, 10 Jan 2023 16:22:21 +0400 Subject: [PATCH] core: fix live file transfers queries (#1715) --- src/Simplex/Chat.hs | 2 +- src/Simplex/Chat/Store.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index b708e293a9..8ed7ab6641 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -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)] diff --git a/src/Simplex/Chat/Store.hs b/src/Simplex/Chat/Store.hs index 1fc311f282..fd5e27b773 100644 --- a/src/Simplex/Chat/Store.hs +++ b/src/Simplex/Chat/Store.hs @@ -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