From 46bc9471282713dc25c7ccca6a00458e1d28b5f7 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:53:24 +0400 Subject: [PATCH] getAgentSubsSummary api --- apps/ios/Shared/Model/SimpleXAPI.swift | 7 +++++++ apps/ios/Shared/Views/ChatList/ServersSummaryView.swift | 2 ++ apps/ios/SimpleXChat/APITypes.swift | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/apps/ios/Shared/Model/SimpleXAPI.swift b/apps/ios/Shared/Model/SimpleXAPI.swift index a9511124c2..3c7e5da589 100644 --- a/apps/ios/Shared/Model/SimpleXAPI.swift +++ b/apps/ios/Shared/Model/SimpleXAPI.swift @@ -1350,6 +1350,13 @@ func resetAgentServersStats() async throws { try await sendCommandOkResp(.resetAgentServersStats) } +func getAgentSubsSummary() throws -> SMPServerSubs { + let userId = try currentUserId("getAgentSubsSummary") + let r = chatSendCmdSync(.getAgentSubsSummary(userId: userId)) + if case let .agentSubsSummary(_, subsSummary) = r { return subsSummary } + throw r +} + private func currentUserId(_ funcName: String) throws -> Int64 { if let userId = ChatModel.shared.currentUser?.userId { return userId diff --git a/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift b/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift index 779c625b24..db657d2c71 100644 --- a/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift +++ b/apps/ios/Shared/Views/ChatList/ServersSummaryView.swift @@ -470,6 +470,8 @@ struct SMPServerSummaryView: View { indentedInfoRow("duplicates", "\(stats._recvDuplicates)") indentedInfoRow("decryption", "\(stats._recvCryptoErrs)") indentedInfoRow("other errors", "\(stats._recvErrs)") + infoRow("Messages acknowledged", "\(stats._ackMsgs)") + indentedInfoRow("attempts", "\(stats._ackAttempts)") infoRow("Connections created", "\(stats._connCreated)") indentedInfoRow("secured", "\(stats._connSecured)") indentedInfoRow("completed", "\(stats._connCompleted)") diff --git a/apps/ios/SimpleXChat/APITypes.swift b/apps/ios/SimpleXChat/APITypes.swift index e81c84c648..c6e9f47b58 100644 --- a/apps/ios/SimpleXChat/APITypes.swift +++ b/apps/ios/SimpleXChat/APITypes.swift @@ -146,6 +146,7 @@ public enum ChatCommand { case showVersion case getAgentServersSummary(userId: Int64) case resetAgentServersStats + case getAgentSubsSummary(userId: Int64) case string(String) public var cmdString: String { @@ -308,6 +309,7 @@ public enum ChatCommand { case .showVersion: return "/version" case let .getAgentServersSummary(userId): return "/get servers summary \(userId)" case .resetAgentServersStats: return "/reset servers stats" + case let .getAgentSubsSummary(userId): return "/get subs summary \(userId)" case let .string(str): return str } } @@ -445,6 +447,7 @@ public enum ChatCommand { case .showVersion: return "showVersion" case .getAgentServersSummary: return "getAgentServersSummary" case .resetAgentServersStats: return "resetAgentServersStats" + case .getAgentSubsSummary: return "getAgentSubsSummary" case .string: return "console command" } } @@ -674,6 +677,7 @@ public enum ChatResponse: Decodable, Error { case versionInfo(versionInfo: CoreVersionInfo, chatMigrations: [UpMigration], agentMigrations: [UpMigration]) case cmdOk(user: UserRef?) case agentServersSummary(user: UserRef, serversSummary: PresentedServersSummary) + case agentSubsSummary(user: UserRef, subsSummary: SMPServerSubs) case chatCmdError(user_: UserRef?, chatError: ChatError) case chatError(user_: UserRef?, chatError: ChatError) case archiveImported(archiveErrors: [ArchiveError]) @@ -833,6 +837,7 @@ public enum ChatResponse: Decodable, Error { case .versionInfo: return "versionInfo" case .cmdOk: return "cmdOk" case .agentServersSummary: return "agentServersSummary" + case .agentSubsSummary: return "agentSubsSummary" case .chatCmdError: return "chatCmdError" case .chatError: return "chatError" case .archiveImported: return "archiveImported" @@ -997,6 +1002,7 @@ public enum ChatResponse: Decodable, Error { case let .versionInfo(versionInfo, chatMigrations, agentMigrations): return "\(String(describing: versionInfo))\n\nchat migrations: \(chatMigrations.map(\.upName))\n\nagent migrations: \(agentMigrations.map(\.upName))" case .cmdOk: return noDetails case let .agentServersSummary(u, serversSummary): return withUser(u, String(describing: serversSummary)) + case let .agentSubsSummary(u, subsSummary): return withUser(u, String(describing: subsSummary)) case let .chatCmdError(u, chatError): return withUser(u, String(describing: chatError)) case let .chatError(u, chatError): return withUser(u, String(describing: chatError)) case let .archiveImported(archiveErrors): return String(describing: archiveErrors) @@ -2308,6 +2314,8 @@ public struct AgentSMPServerStatsData: Codable { public var _recvDuplicates: Int public var _recvCryptoErrs: Int public var _recvErrs: Int + public var _ackMsgs: Int + public var _ackAttempts: Int public var _connCreated: Int public var _connSecured: Int public var _connCompleted: Int