@@ -1357,7 +1357,6 @@ forkClient Client {endThreads, endThreadSeq} label action = do
13571357
13581358client :: forall s . MsgStoreClass s => Server s -> s -> Client s -> M s ()
13591359client
1360- -- TODO [certs rcv] rcv subscriptions
13611360 Server {subscribers, ntfSubscribers}
13621361 ms
13631362 clnt@ Client {clientId, rcvQ, sndQ, msgQ, clientTHParams = thParams'@ THandleParams {sessionId}, procThreads} = do
@@ -1805,23 +1804,27 @@ client
18051804 pure $ SOKS count idsHash
18061805 where
18071806 deliverServiceMessages expectedCnt = do
1808- (qCnt, _msgCnt, _dupCnt, _errCnt) <- foldRcvServiceMessages ms serviceId deliverQueueMsg (0 , 0 , 0 , 0 )
1809- atomically $ writeTBQueue msgQ [(NoCorrId , NoEntity , ALLS )]
1810- -- TODO [certs rcv] compare with expected
1811- logNote $ " Service subscriptions for " <> tshow serviceId <> " (" <> tshow qCnt <> " queues)"
1812- deliverQueueMsg :: (Int , Int , Int , Int ) -> RecipientId -> Either ErrorType (Maybe (QueueRec , Message )) -> IO (Int , Int , Int , Int )
1813- deliverQueueMsg (! qCnt, ! msgCnt, ! dupCnt, ! errCnt) rId = \ case
1814- Left e -> pure (qCnt + 1 , msgCnt, dupCnt, errCnt + 1 ) -- TODO [certs rcv] deliver subscription error
1807+ foldRcvServiceMessages ms serviceId deliverQueueMsg (0 , 0 , 0 , [] ) >>= \ case
1808+ Right (qCnt, _msgCnt, _dupCnt, _errCnt) -> do
1809+ atomically $ writeTBQueue msgQ [(NoCorrId , NoEntity , ALLS )]
1810+ -- TODO [certs rcv] compare with expected
1811+ logNote $ " Service subscriptions for " <> tshow serviceId <> " (" <> tshow qCnt <> " queues)"
1812+ Left e -> do
1813+ -- TODO [certs rcv] deliver SMP error
1814+ logError $ " Service subscriptions for " <> tshow serviceId <> " error: " <> tshow e
1815+ deliverQueueMsg :: (Int , Int , Int , [ErrorType ]) -> RecipientId -> Either ErrorType (Maybe (QueueRec , Message )) -> IO (Int , Int , Int , [ErrorType ])
1816+ deliverQueueMsg (! qCnt, ! msgCnt, ! dupCnt, ! errs) rId = \ case
1817+ Left e -> pure (qCnt + 1 , msgCnt, dupCnt, e : errs) -- TODO [certs rcv] deliver subscription error
18151818 Right qMsg_ -> case qMsg_ of
1816- Nothing -> pure (qCnt + 1 , msgCnt, dupCnt, errCnt )
1819+ Nothing -> pure (qCnt + 1 , msgCnt, dupCnt, errs )
18171820 Just (qr, msg) ->
18181821 atomically (getSubscription rId) >>= \ case
1819- Nothing -> pure (qCnt + 1 , msgCnt, dupCnt + 1 , errCnt )
1822+ Nothing -> pure (qCnt + 1 , msgCnt, dupCnt + 1 , errs )
18201823 Just sub -> do
18211824 ts <- getSystemSeconds
18221825 atomically $ setDelivered sub msg ts
18231826 atomically $ writeTBQueue msgQ [(NoCorrId , rId, MSG (encryptMsg qr msg))]
1824- pure (qCnt + 1 , msgCnt + 1 , dupCnt, errCnt )
1827+ pure (qCnt + 1 , msgCnt + 1 , dupCnt, errs )
18251828 getSubscription rId =
18261829 TM. lookup rId (subscriptions clnt) >>= \ case
18271830 -- If delivery subscription already exists, then there is no need to deliver message.
0 commit comments