@@ -963,24 +963,24 @@ smpServer started cfg@ServerConfig {transports, transportConfig = tCfg, startOpt
963963 SubPending -> (c1, c2 + 1 , c3, c4)
964964 SubThread _ -> (c1, c2, c3 + 1 , c4)
965965 ProhibitSub -> pure (c1, c2, c3, c4 + 1 )
966- CPDelete sId -> withAdminRole $ unliftIO u $ do
966+ CPDelete qId -> withAdminRole $ unliftIO u $ do
967967 st <- asks msgStore
968968 r <- liftIO $ runExceptT $ do
969- q <- ExceptT $ getQueue st SSender sId
969+ (q, _) <- ExceptT $ getSenderQueue st qId
970970 ExceptT $ deleteQueueSize st q
971971 case r of
972972 Left e -> liftIO $ hPutStrLn h $ " error: " <> show e
973973 Right (qr, numDeleted) -> do
974974 updateDeletedStats qr
975975 liftIO $ hPutStrLn h $ " ok, " <> show numDeleted <> " messages deleted"
976- CPStatus sId -> withUserRole $ unliftIO u $ do
976+ CPStatus qId -> withUserRole $ unliftIO u $ do
977977 st <- asks msgStore
978- q <- liftIO $ getQueueRec st SSender sId
978+ q <- liftIO $ getSenderQueue st qId
979979 liftIO $ hPutStrLn h $ case q of
980980 Left e -> " error: " <> show e
981981 Right (_, QueueRec {queueMode, status, updatedAt}) ->
982982 " status: " <> show status <> " , updatedAt: " <> show updatedAt <> " , queueMode: " <> show queueMode
983- CPBlock sId info -> withUserRole $ unliftIO u $ do
983+ CPBlock qId info -> withUserRole $ unliftIO u $ do
984984 st <- asks msgStore
985985 stats <- asks serverStats
986986 blocked <- liftIO $ readIORef $ qBlocked stats
@@ -989,7 +989,7 @@ smpServer started cfg@ServerConfig {transports, transportConfig = tCfg, startOpt
989989 then liftIO $ hPutStrLn h $ " error: reached limit of " <> show quota <> " queues blocked daily"
990990 else do
991991 r <- liftIO $ runExceptT $ do
992- (q, QueueRec {status}) <- ExceptT $ getQueueRec st SSender sId
992+ (q, QueueRec {status}) <- ExceptT $ getSenderQueue st qId
993993 when (status == EntityActive ) $ ExceptT $ blockQueue (queueStore st) q info
994994 pure status
995995 case r of
@@ -998,14 +998,18 @@ smpServer started cfg@ServerConfig {transports, transportConfig = tCfg, startOpt
998998 incStat $ qBlocked stats
999999 liftIO $ hPutStrLn h " ok, queue blocked"
10001000 Right status -> liftIO $ hPutStrLn h $ " ok, already inactive: " <> show status
1001- CPUnblock sId -> withUserRole $ unliftIO u $ do
1001+ CPUnblock qId -> withUserRole $ unliftIO u $ do
10021002 st <- asks msgStore
10031003 r <- liftIO $ runExceptT $ do
1004- q <- ExceptT $ getQueue st SSender sId
1005- ExceptT $ unblockQueue (queueStore st) q
1004+ (q, QueueRec {status}) <- ExceptT $ getSenderQueue st qId
1005+ case status of
1006+ EntityBlocked info -> Right info <$ ExceptT (unblockQueue (queueStore st) q)
1007+ EntityActive -> pure $ Left True
1008+ EntityOff -> pure $ Left False
10061009 liftIO $ hPutStrLn h $ case r of
10071010 Left e -> " error: " <> show e
1008- Right () -> " ok, queue unblocked"
1011+ Right (Right info) -> " ok, queue unblocked, reason to block was: " <> show info
1012+ Right (Left unblocked) -> if unblocked then " ok, queue was active" else " error, queue is inactive"
10091013 CPSave -> withAdminRole $ withLock' (savingLock srv) " control" $ do
10101014 hPutStrLn h " saving server state..."
10111015 unliftIO u $ saveServer False
@@ -1014,6 +1018,11 @@ smpServer started cfg@ServerConfig {transports, transportConfig = tCfg, startOpt
10141018 CPQuit -> pure ()
10151019 CPSkip -> pure ()
10161020 where
1021+ getSenderQueue st qId =
1022+ getQueueRec st SSender qId >>= \ case
1023+ Right r -> pure $ Right r
1024+ Left AUTH -> getQueueRec st SSenderLink qId
1025+ Left e -> pure $ Left e
10171026 withUserRole action = readTVarIO role >>= \ case
10181027 CPRAdmin -> action
10191028 CPRUser -> action
@@ -1508,8 +1517,8 @@ client
15081517 rcvId <- randId
15091518 ntf <- forM ntfKeys_ $ \ (notifierKey, rcvNtfDhSecret, rcvPubDhKey) -> do
15101519 notifierId <- randId
1511- let ntfCreds = NtfCreds {notifierId, notifierKey, rcvNtfDhSecret, ntfServiceId = Nothing }
1512- pure (ntfCreds, ServerNtfCreds notifierId rcvPubDhKey)
1520+ let ntfCreds' = NtfCreds {notifierId, notifierKey, rcvNtfDhSecret, ntfServiceId = Nothing }
1521+ pure (ntfCreds' , ServerNtfCreds notifierId rcvPubDhKey)
15131522 let queueMode = queueReqMode <$> queueReqData
15141523 qr =
15151524 QueueRec
0 commit comments