From d0f21b943c433d868c7d1677493cd3efc756bd86 Mon Sep 17 00:00:00 2001 From: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com> Date: Tue, 30 Apr 2024 20:10:25 +0300 Subject: [PATCH] debug conn by chat connection id from contact info --- src/Simplex/Chat.hs | 7 +++++-- src/Simplex/Chat/Controller.hs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index d72f02fe45..17e61cee8d 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -2157,7 +2157,10 @@ processChatCommand' vr = \case ads <- mapM readTVarIO =<< readTVarIO =<< asks agentDeliveryStatuses let collect (acId, ds) = if not showAll && agentDeliveryOk ds then Nothing else Just (decodeLatin1 $ strEncode acId, ds) pure $ CRDebugDelivery . M.fromList . mapMaybe collect $ M.toList ads - DebugConnection acId@(AgentConnId acId') -> do + DebugConnection (Left connId) -> withUser $ \user -> do + Connection {agentConnId} <- withStore $ \db -> getConnectionById db vr user connId + processChatCommand $ DebugConnection (Right agentConnId) + DebugConnection (Right acId@(AgentConnId acId')) -> do user@User {userId} <- withStore' (`getUserByAConnId` acId) >>= maybe (throwError . ChatErrorStore $ SEUserNotFoundByAConnId acId) pure AS.RcvQueue {server, rcvId = rcvId', status = rqStatus} <- withAgent $ \ac -> -- dive into agent internals @@ -7385,7 +7388,7 @@ chatCommandP = ("/quit" <|> "/q" <|> "/exit") $> QuitChat, ("/version" <|> "/v") $> ShowVersion, "/debug delivery" *> (DebugDelivery <$> (" all" $> True <|> pure False)), - "/debug conn " *> (DebugConnection . AgentConnId <$> base64P), -- TODO get by decimal connId too + "/debug conn " *> (DebugConnection <$> ((Left <$> A.decimal) <|> (Right . AgentConnId <$> base64P))), "/debug locks" $> DebugLocks, "/debug event " *> (DebugEvent <$> jsonP), "/get stats" $> GetAgentStats, diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index 38c2bb8903..06e78594b5 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -507,7 +507,7 @@ data ChatCommand | QuitChat | ShowVersion | DebugDelivery Bool - | DebugConnection AgentConnId + | DebugConnection (Either Int64 AgentConnId) | DebugLocks | DebugEvent ChatResponse | GetAgentStats