mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-05-25 20:44:49 +00:00
func
This commit is contained in:
@@ -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 ()
|
||||
|
||||
@@ -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 $
|
||||
|
||||
Reference in New Issue
Block a user