diff --git a/src/Simplex/Messaging/Server.hs b/src/Simplex/Messaging/Server.hs index 63b24b8b3..0eafd4ff4 100644 --- a/src/Simplex/Messaging/Server.hs +++ b/src/Simplex/Messaging/Server.hs @@ -1108,15 +1108,14 @@ receive h@THandle {params = THandleParams {thAuth, sessionId}} ms Client {rcvQ, verified :: ServerStats -> SignedTransmission Cmd -> VerificationResult s -> IO (VerifiedTransmissionOrError s) verified stats (_, _, t@(corrId, entId, Cmd _ command)) = \case VRVerified q -> pure $ Right (q, t) - VRFailed AUTH -> do - case command of - SEND {} -> incStat $ msgSentAuth stats - SUB -> incStat $ qSubAuth stats - NSUB -> incStat $ ntfSubAuth stats - GET -> incStat $ msgGetAuth stats - _ -> pure () - pure $ Left (corrId, entId, ERR AUTH) - VRFailed e -> pure $ Left (corrId, entId, ERR e) + VRFailed e -> Left (corrId, entId, ERR e) <$ when (e == AUTH) incAuthStat + where + incAuthStat = case command of + SEND {} -> incStat $ msgSentAuth stats + SUB -> incStat $ qSubAuth stats + NSUB -> incStat $ ntfSubAuth stats + GET -> incStat $ msgGetAuth stats + _ -> pure () write q = mapM_ (atomically . writeTBQueue q) . L.nonEmpty send :: Transport c => MVar (THandleSMP c 'TServer) -> Client s -> IO () diff --git a/src/Simplex/Messaging/Server/QueueStore/Postgres.hs b/src/Simplex/Messaging/Server/QueueStore/Postgres.hs index 35667fa62..f440b9d5b 100644 --- a/src/Simplex/Messaging/Server/QueueStore/Postgres.hs +++ b/src/Simplex/Messaging/Server/QueueStore/Postgres.hs @@ -258,9 +258,8 @@ instance StoreQueueClass q => QueueStoreClass q (PostgresQueueStore q) where pure $ map (result qs_) qs' where result :: Either ErrorType (M.Map QueueId q) -> Either QueueId q -> Either ErrorType q - result qs_ = \case - Right q -> Right q - Left qId -> maybe (Left AUTH) Right . M.lookup qId =<< qs_ + result _ (Right q) = Right q + result qs_ (Left qId) = maybe (Left AUTH) Right . M.lookup qId =<< qs_ cacheRcvQueue (rId, qRec) = do sq <- mkQ True rId qRec sq' <- withQueueLock sq "getQueue_" $ atomically $