mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-24 20:20:51 +00:00
Fix inline bot geo queries
This commit is contained in:
parent
6f8759c501
commit
9754e564ab
@ -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<ChatContextResultCollection?, RequestChatContextResultsError> {
|
||||
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<ChatContextResultCollection?, RequestChatContextResultsError> in
|
||||
if let (bot, peer) = botAndPeer, let inputBot = apiInputUser(bot) {
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user