From 174568088ad03a1a66d6855bf86c4dcd46c62814 Mon Sep 17 00:00:00 2001 From: Kylmakalle Date: Tue, 4 Feb 2025 22:04:19 +0200 Subject: [PATCH] Log IQTP issues --- Swiftgram/SGIQTP/Sources/SGIQTP.swift | 2 +- .../Messages/RequestChatContextResults.swift | 8 ++++++-- .../TelegramEngine/Messages/TelegramEngineMessages.swift | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Swiftgram/SGIQTP/Sources/SGIQTP.swift b/Swiftgram/SGIQTP/Sources/SGIQTP.swift index 529b417486..5063537930 100644 --- a/Swiftgram/SGIQTP/Sources/SGIQTP.swift +++ b/Swiftgram/SGIQTP/Sources/SGIQTP.swift @@ -42,7 +42,7 @@ public func sgIqtpQuery(engine: TelegramEngine, query: String, incompleteResults SGLogger.shared.log("SGIQTP", "[\(queryId)] Empty peer") return .single(nil) } - return engine.messages.requestChatContextResults(botId: peer.id, peerId: engine.account.peerId, query: query, offset: "", incompleteResults: incompleteResults, staleCachedResults: staleCachedResults) + return engine.messages.requestChatContextResults(IQTP: true, botId: peer.id, peerId: engine.account.peerId, query: query, offset: "", incompleteResults: incompleteResults, staleCachedResults: staleCachedResults) |> map { results -> ChatContextResultCollection? in return results?.results } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/RequestChatContextResults.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/RequestChatContextResults.swift index 4165f16b18..91bc2884c3 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/RequestChatContextResults.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/RequestChatContextResults.swift @@ -1,3 +1,4 @@ +import SGLogging import Foundation import Postbox import SwiftSignalKit @@ -52,7 +53,7 @@ public struct RequestChatContextResultsResult { } } -func _internal_requestChatContextResults(account: Account, botId: PeerId, peerId: PeerId, query: String, location: Signal<(Double, Double)?, NoError> = .single(nil), offset: String, incompleteResults: Bool = false, staleCachedResults: Bool = false) -> Signal { +func _internal_requestChatContextResults(IQTP: Bool = false, account: Account, botId: PeerId, peerId: PeerId, query: String, location: Signal<(Double, Double)?, NoError> = .single(nil), offset: String, incompleteResults: Bool = false, staleCachedResults: Bool = false) -> Signal { return account.postbox.transaction { transaction -> (bot: Peer, peer: Peer)? in if let bot = transaction.getPeer(botId), let peer = transaction.getPeer(peerId) { return (bot, peer) @@ -127,7 +128,10 @@ func _internal_requestChatContextResults(account: Account, botId: PeerId, peerId return ChatContextResultCollection(apiResults: result, botId: bot.id, peerId: peerId, query: query, geoPoint: location) } |> mapError { error -> RequestChatContextResultsError in - print("error.errorDescription", error.errorDescription ?? "") + // MARK: Swiftgram + if IQTP { + SGLogger.shared.log("SGIQTP", "Error requesting inline results: \(error.errorDescription ?? "nil")") + } if error.errorDescription == "BOT_INLINE_GEO_REQUIRED" { return .locationRequired } else { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift index c0acab773b..16a025c4d7 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift @@ -361,8 +361,8 @@ public extension TelegramEngine { return _internal_updateStarsReactionIsAnonymous(account: self.account, messageId: id, isAnonymous: isAnonymous) } - public func requestChatContextResults(botId: PeerId, peerId: PeerId, query: String, location: Signal<(Double, Double)?, NoError> = .single(nil), offset: String, incompleteResults: Bool = false, staleCachedResults: Bool = false) -> Signal { - return _internal_requestChatContextResults(account: self.account, botId: botId, peerId: peerId, query: query, location: location, offset: offset, incompleteResults: incompleteResults, staleCachedResults: staleCachedResults) + public func requestChatContextResults(IQTP: Bool = false, botId: PeerId, peerId: PeerId, query: String, location: Signal<(Double, Double)?, NoError> = .single(nil), offset: String, incompleteResults: Bool = false, staleCachedResults: Bool = false) -> Signal { + return _internal_requestChatContextResults(IQTP: IQTP, account: self.account, botId: botId, peerId: peerId, query: query, location: location, offset: offset, incompleteResults: incompleteResults, staleCachedResults: staleCachedResults) } public func removeRecentlyUsedHashtag(string: String) -> Signal {