Compare commits

...

17 Commits

Author SHA1 Message Date
Evgeny Poberezkin 0d62d7ddfb Merge branch 'master' into ab/diff-subs 2024-05-28 08:06:25 +01:00
Evgeny Poberezkin a78aeb47c5 Merge branch 'master' into ab/diff-subs 2024-05-27 16:00:55 +01:00
IC Rainbow 94df5d47d1 Merge remote-tracking branch 'origin/master' into ab/diff-subs 2024-05-20 13:11:55 +03:00
Evgeny Poberezkin f9cba3f8e0 Merge branch 'master' into ab/diff-subs 2024-05-16 19:11:49 +01:00
Evgeny Poberezkin 3655971aec Merge branch 'master' into ab/diff-subs 2024-05-15 13:57:39 +01:00
Alexander Bondarenko dea45e3228 Merge remote-tracking branch 'origin/master' into ab/diff-subs 2024-05-15 14:58:08 +03:00
Alexander Bondarenko 4f2102ac6e use user and diff filters 2024-05-14 16:56:28 +03:00
IC Rainbow 17bcdaf6c4 Merge remote-tracking branch 'origin/master' into ab/diff-subs 2024-05-14 13:41:38 +03:00
IC Rainbow 1a2fad070e Merge remote-tracking branch 'origin/master' into ab/diff-subs 2024-05-13 15:56:29 +03:00
IC Rainbow 6101be5657 update mq 2024-05-12 21:55:35 +03:00
Evgeny Poberezkin a10dd81a1d Merge branch 'master' into ab/diff-subs 2024-05-12 12:07:26 +01:00
Evgeny Poberezkin 289130832a Merge branch 'master' into ab/diff-subs 2024-05-11 23:59:15 +01:00
Evgeny Poberezkin 224cfe9e02 Merge branch 'master' into ab/diff-subs 2024-05-11 13:07:05 +01:00
Alexander Bondarenko 0679d023e2 Merge remote-tracking branch 'origin/master' into ab/diff-subs 2024-05-10 21:01:33 +03:00
Alexander Bondarenko 6d5869e974 Merge remote-tracking branch 'origin/master' into ab/diff-subs 2024-05-08 16:42:54 +03:00
Alexander Bondarenko f0974af03a sync 2024-05-08 16:13:42 +03:00
Alexander Bondarenko da70aa30b6 debug: use client diffs in /get subs 2024-05-08 16:09:05 +03:00
5 changed files with 14 additions and 35 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ constraints: zip +disable-bzip2 +disable-zstd
source-repository-package
type: git
location: https://github.com/simplex-chat/simplexmq.git
tag: bd67844169d2206d8543c01e6ed966315115b0e3
tag: e2f4ffc9db8e3812cfaf12ded9904061fb330fd6
source-repository-package
type: git
+1 -1
View File
@@ -1,5 +1,5 @@
{
"https://github.com/simplex-chat/simplexmq.git"."bd67844169d2206d8543c01e6ed966315115b0e3" = "1g218q15hrg21h8gyidavfys5zx8dzmxq7iwfm5bfaw71grpd7pn";
"https://github.com/simplex-chat/simplexmq.git"."e2f4ffc9db8e3812cfaf12ded9904061fb330fd6" = "0mvg8wn8brcw71fh0lsf39lypha2kfil443bq7gz6zhwl87vaz28";
"https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38";
"https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d";
"https://github.com/simplex-chat/sqlcipher-simple.git"."a46bd361a19376c5211f1058908fc0ae6bf42446" = "1z0r78d8f0812kxbgsm735qf6xx8lvaz27k1a0b4a2m0sshpd5gl";
+2 -16
View File
@@ -2233,20 +2233,7 @@ processChatCommand' vr = \case
counts <- map (first decodeLatin1) <$> withAgent' getMsgCounts
let allMsgs = foldl' (\(ts, ds) (_, (t, d)) -> (ts + t, ds + d)) (0, 0) counts
pure CRAgentMsgCounts {msgCounts = ("all", allMsgs) : sortOn (Down . snd) (filter (\(_, (_, d)) -> d /= 0) counts)}
GetAgentSubs -> lift $ summary <$> withAgent' getAgentSubscriptions
where
summary SubscriptionsInfo {activeSubscriptions, pendingSubscriptions, removedSubscriptions} =
CRAgentSubs
{ activeSubs = foldl' countSubs M.empty activeSubscriptions,
pendingSubs = foldl' countSubs M.empty pendingSubscriptions,
removedSubs = foldl' accSubErrors M.empty removedSubscriptions
}
where
countSubs m SubInfo {server} = M.alter (Just . maybe 1 (+ 1)) server m
accSubErrors m = \case
SubInfo {server, subError = Just e} -> M.alter (Just . maybe [e] (e :)) server m
_ -> m
GetAgentSubsDetails -> lift $ CRAgentSubsDetails <$> withAgent' getAgentSubscriptions
GetAgentSubs diff -> withUser $ \User {userId} -> lift $ CRAgentSubs <$> withAgent' (\a -> getAgentSubscriptions a diff (Just userId))
-- CustomChatCommand is unsupported, it can be processed in preCmdHook
-- in a modified CLI app or core - the hook should return Either ChatResponse ChatCommand
CustomChatCommand _cmd -> withUser $ \user -> pure $ chatCmdError (Just user) "not supported"
@@ -7489,8 +7476,7 @@ chatCommandP =
"/debug event " *> (DebugEvent <$> jsonP),
"/get stats" $> GetAgentStats,
"/reset stats" $> ResetAgentStats,
"/get subs" $> GetAgentSubs,
"/get subs details" $> GetAgentSubsDetails,
"/get subs" *> (GetAgentSubs <$> (" diff" $> True <|> pure False)),
"/get workers" $> GetAgentWorkers,
"/get workers details" $> GetAgentWorkersDetails,
"/get msgs" $> GetAgentMsgCounts,
+2 -4
View File
@@ -499,8 +499,7 @@ data ChatCommand
| DebugEvent ChatResponse
| GetAgentStats
| ResetAgentStats
| GetAgentSubs
| GetAgentSubsDetails
| GetAgentSubs {diffOnly :: Bool}
| GetAgentWorkers
| GetAgentWorkersDetails
| GetAgentMsgCounts
@@ -747,8 +746,7 @@ data ChatResponse
| CRAgentStats {agentStats :: [[String]]}
| CRAgentWorkersDetails {agentWorkersDetails :: AgentWorkersDetails}
| CRAgentWorkersSummary {agentWorkersSummary :: AgentWorkersSummary}
| CRAgentSubs {activeSubs :: Map Text Int, pendingSubs :: Map Text Int, removedSubs :: Map Text [String]}
| CRAgentSubsDetails {agentSubs :: SubscriptionsInfo}
| CRAgentSubs {agentSubs :: SubscriptionsInfo}
| CRAgentMsgCounts {msgCounts :: [(Text, (Int, Int))]}
| CRContactDisabled {user :: User, contact :: Contact}
| CRConnectionDisabled {connectionEntity :: ConnectionEntity}
+8 -13
View File
@@ -22,7 +22,6 @@ import Data.Int (Int64)
import Data.List (groupBy, intercalate, intersperse, partition, sortOn)
import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.List.NonEmpty as L
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import Data.Maybe (fromMaybe, isJust, isNothing, mapMaybe)
import Data.Text (Text)
@@ -52,7 +51,7 @@ import Simplex.Chat.Types.Preferences
import Simplex.Chat.Types.Shared
import Simplex.Chat.Types.UITheme
import qualified Simplex.FileTransfer.Transport as XFTP
import Simplex.Messaging.Agent.Client (ProtocolTestFailure (..), ProtocolTestStep (..), SubscriptionsInfo (..))
import Simplex.Messaging.Agent.Client (ActivePendingSubs (..), ProtocolTestFailure (..), ProtocolTestStep (..), SubInfo (..), SubscriptionsInfo (..))
import Simplex.Messaging.Agent.Env.SQLite (NetworkConfig (..))
import Simplex.Messaging.Agent.Protocol
import Simplex.Messaging.Agent.Store.SQLite.DB (SlowQueryStats (..))
@@ -358,18 +357,14 @@ responseToView hu@(currentRH, user_) ChatConfig {logLevel, showReactions, showRe
plain $ "agent locks: " <> LB.unpack (J.encode agentLocks)
]
CRAgentStats stats -> map (plain . intercalate ",") stats
CRAgentSubs {activeSubs, pendingSubs, removedSubs} ->
[plain $ "Subscriptions: active = " <> show (sum activeSubs) <> ", pending = " <> show (sum pendingSubs) <> ", removed = " <> show (sum $ M.map length removedSubs)]
<> ("active subscriptions:" : listSubs activeSubs)
<> ("pending subscriptions:" : listSubs pendingSubs)
<> ("removed subscriptions:" : listSubs removedSubs)
CRAgentSubs SubscriptionsInfo {summary, servers} -> "Subscriptions:" : activePending summary <> concatMap (uncurry byServer) (M.assocs servers)
where
listSubs :: Show a => Map Text a -> [StyledString]
listSubs = map (\(srv, info) -> plain $ srv <> ": " <> tshow info) . M.assocs
CRAgentSubsDetails SubscriptionsInfo {activeSubscriptions, pendingSubscriptions, removedSubscriptions} ->
("active subscriptions:" : map sShow activeSubscriptions)
<> ("pending subscriptions: " : map sShow pendingSubscriptions)
<> ("removed subscriptions: " : map sShow removedSubscriptions)
byServer srv aps = plain srv : activePending aps
activePending ActivePendingSubs {active_, pending_} =
[ " active: " <> subInfo active_,
" pending: " <> subInfo pending_
]
subInfo SubInfo {count, clientsMissing, clientsExtra} = sShow count <> " (clients: -" <> sShow clientsMissing <> " +" <> sShow clientsExtra <> ")"
CRAgentWorkersSummary {agentWorkersSummary} -> ["agent workers summary: " <> plain (LB.unpack $ J.encode agentWorkersSummary)]
CRAgentWorkersDetails {agentWorkersDetails} ->
[ "agent workers details:",