diff --git a/submodules/TelegramCore/TelegramCore/RequestChatContextResults.swift b/submodules/TelegramCore/TelegramCore/RequestChatContextResults.swift index a513dbe769..8dc3abad29 100644 --- a/submodules/TelegramCore/TelegramCore/RequestChatContextResults.swift +++ b/submodules/TelegramCore/TelegramCore/RequestChatContextResults.swift @@ -21,13 +21,24 @@ public enum RequestChatContextResultsError { } public func requestChatContextResults(account: Account, botId: PeerId, peerId: PeerId, query: String, location: Signal<(Double, Double)?, NoError> = .single(nil), offset: String) -> Signal { - return combineLatest(account.postbox.transaction { transaction -> (bot: Peer, peer: Peer)? in + return account.postbox.transaction { transaction -> (bot: Peer, peer: Peer)? in if let bot = transaction.getPeer(botId), let peer = transaction.getPeer(peerId) { return (bot, peer) } else { return nil } - }, location) + } + |> mapToSignal { botAndPeer -> Signal<((bot: Peer, peer: Peer)?, (Double, Double)?), NoError> in + if let (bot, _) = botAndPeer, let botUser = bot as? TelegramUser, let botInfo = botUser.botInfo, botInfo.flags.contains(.requiresGeolocationForInlineRequests) { + return location + |> take(1) + |> map { location -> ((bot: Peer, peer: Peer)?, (Double, Double)?) in + return (botAndPeer, location) + } + } else { + return .single((botAndPeer, nil)) + } + } |> castError(RequestChatContextResultsError.self) |> mapToSignal { botAndPeer, location -> Signal in if let (bot, peer) = botAndPeer, let inputBot = apiInputUser(bot) { diff --git a/submodules/TelegramCore/TelegramCore/TelegramUser.swift b/submodules/TelegramCore/TelegramCore/TelegramUser.swift index f23265ce6c..3991cc7e60 100644 --- a/submodules/TelegramCore/TelegramCore/TelegramUser.swift +++ b/submodules/TelegramCore/TelegramCore/TelegramUser.swift @@ -37,7 +37,7 @@ public struct BotUserInfoFlags: OptionSet { public static let hasAccessToChatHistory = BotUserInfoFlags(rawValue: (1 << 0)) public static let worksWithGroups = BotUserInfoFlags(rawValue: (1 << 1)) - public static let requiresGeolocationForInlineRequests = BotUserInfoFlags(rawValue: (1 << 2)) + public static let requiresGeolocationForInlineRequests = BotUserInfoFlags(rawValue: (1 << 3)) } public struct BotUserInfo: PostboxCoding, Equatable { @@ -319,7 +319,7 @@ extension TelegramUser { if (flags & (1 << 16)) == 0 { botFlags.insert(.worksWithGroups) } - if (flags & (1 << 21)) == 0 { + if (flags & (1 << 21)) != 0 { botFlags.insert(.requiresGeolocationForInlineRequests) } botInfo = BotUserInfo(flags: botFlags, inlinePlaceholder: botInlinePlaceholder) @@ -362,7 +362,7 @@ extension TelegramUser { if (flags & (1 << 16)) == 0 { botFlags.insert(.worksWithGroups) } - if (flags & (1 << 21)) == 0 { + if (flags & (1 << 21)) != 0 { botFlags.insert(.requiresGeolocationForInlineRequests) } botInfo = BotUserInfo(flags: botFlags, inlinePlaceholder: botInlinePlaceholder)