From f3849e57693e6100f78f905e141ce04bd713f3aa Mon Sep 17 00:00:00 2001 From: Peter <> Date: Wed, 23 Oct 2019 22:29:03 +0400 Subject: [PATCH 1/3] Fix notification token passing --- submodules/MtProtoKit/MTProtoKit/MTRequestMessageService.m | 3 +++ submodules/TelegramUI/TelegramUI/AppDelegate.swift | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/submodules/MtProtoKit/MTProtoKit/MTRequestMessageService.m b/submodules/MtProtoKit/MTProtoKit/MTRequestMessageService.m index e38b892aa7..17c09abe21 100644 --- a/submodules/MtProtoKit/MTProtoKit/MTRequestMessageService.m +++ b/submodules/MtProtoKit/MTProtoKit/MTRequestMessageService.m @@ -291,6 +291,9 @@ if (initializeApi && _apiEnvironment != nil) { + if (MTLogEnabled()) { + MTLog(@"apiEnvironment: %d", (int)_apiEnvironment.systemCode.length); + } MTBuffer *buffer = [[MTBuffer alloc] init]; // invokeWithLayer diff --git a/submodules/TelegramUI/TelegramUI/AppDelegate.swift b/submodules/TelegramUI/TelegramUI/AppDelegate.swift index 5303bfa24a..396ec706f0 100644 --- a/submodules/TelegramUI/TelegramUI/AppDelegate.swift +++ b/submodules/TelegramUI/TelegramUI/AppDelegate.swift @@ -251,8 +251,9 @@ final class SharedApplicationContext { precondition(!testIsLaunched) testIsLaunched = true - self.deviceToken.set(voipTokenPromise.get() - |> map(Optional.init)) + let _ = voipTokenPromise.get().start(next: { token in + self.deviceToken.set(.single(token)) + }) let launchStartTime = CFAbsoluteTimeGetCurrent() From 6f8759c501efe6a1d48a5d033c8d48572f3652fb Mon Sep 17 00:00:00 2001 From: Peter <> Date: Wed, 23 Oct 2019 22:29:14 +0400 Subject: [PATCH 2/3] Fix overlay status check --- .../Sources/OverlayStatusController.swift | 6 +++--- submodules/OverlayStatusController/Sources/ProxyWindow.h | 2 +- submodules/OverlayStatusController/Sources/ProxyWindow.m | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/submodules/OverlayStatusController/Sources/OverlayStatusController.swift b/submodules/OverlayStatusController/Sources/OverlayStatusController.swift index 82fd76fe5b..712a3297ec 100644 --- a/submodules/OverlayStatusController/Sources/OverlayStatusController.swift +++ b/submodules/OverlayStatusController/Sources/OverlayStatusController.swift @@ -92,13 +92,13 @@ private final class OverlayStatusControllerNode: ViewControllerTracingNode { case .success: self.contentController = .progress(ProgressWindowController(light: style == .light)) case let .shieldSuccess(text, increasedDelay): - self.contentController = .shieldSuccess(ProxyWindowController(light: style == .light, text: text, icon: ProxyWindowController.generateShieldImage(style == .light), isShield: true), increasedDelay) + self.contentController = .shieldSuccess(ProxyWindowController(light: style == .light, text: text, icon: ProxyWindowController.generateShieldImage(style == .light), isShield: true, showCheck: true), increasedDelay) case let .genericSuccess(text, increasedDelay): - let controller = ProxyWindowController(light: style == .light, text: text, icon: nil, isShield: false)! + let controller = ProxyWindowController(light: style == .light, text: text, icon: nil, isShield: false, showCheck: true)! self.contentController = .genericSuccess(controller, increasedDelay) isUserInteractionEnabled = false case let .starSuccess(text): - self.contentController = .genericSuccess(ProxyWindowController(light: style == .light, text: text, icon: UIImage(bundleImageName: "Star"), isShield: false), false) + self.contentController = .genericSuccess(ProxyWindowController(light: style == .light, text: text, icon: UIImage(bundleImageName: "Star"), isShield: false, showCheck: false), false) } super.init() diff --git a/submodules/OverlayStatusController/Sources/ProxyWindow.h b/submodules/OverlayStatusController/Sources/ProxyWindow.h index 2576321ac1..2c332921e5 100644 --- a/submodules/OverlayStatusController/Sources/ProxyWindow.h +++ b/submodules/OverlayStatusController/Sources/ProxyWindow.h @@ -2,7 +2,7 @@ @interface ProxyWindowController : UIViewController -- (instancetype)initWithLight:(bool)light text:(NSString *)text icon:(UIImage *)icon isShield:(bool)isShield; +- (instancetype)initWithLight:(bool)light text:(NSString *)text icon:(UIImage *)icon isShield:(bool)isShield showCheck:(bool)showCheck; - (void)dismissWithSuccess:(void (^)(void))completion increasedDelay:(bool)increasedDelay; - (void)updateLayout; diff --git a/submodules/OverlayStatusController/Sources/ProxyWindow.m b/submodules/OverlayStatusController/Sources/ProxyWindow.m index f3b3cefb13..c881313f0d 100644 --- a/submodules/OverlayStatusController/Sources/ProxyWindow.m +++ b/submodules/OverlayStatusController/Sources/ProxyWindow.m @@ -135,6 +135,7 @@ static bool ProxyWindowIsLight = true; NSString *_text; UIImage *_icon; bool _isShield; + bool _showCheck; UIVisualEffectView *_effectView; UIView *_backgroundView; ProxySpinnerView *_spinner; @@ -168,13 +169,14 @@ static bool ProxyWindowIsLight = true; return image; } -- (instancetype)initWithLight:(bool)light text:(NSString *)text icon:(UIImage *)icon isShield:(bool)isShield { +- (instancetype)initWithLight:(bool)light text:(NSString *)text icon:(UIImage *)icon isShield:(bool)isShield showCheck:(bool)showCheck { self = [super init]; if (self != nil) { _light = light; _text = text; _icon = icon; _isShield = isShield; + _showCheck = showCheck; } return self; } @@ -316,7 +318,7 @@ static bool ProxyWindowIsLight = true; dismissBlock(); }]; - if (_isShield) { + if (_isShield || _showCheck) { dispatchAfter(0.15, dispatch_get_main_queue(), ^{ [_spinner setSucceed]; }); From 9754e564abb7ab89981fbc5c0285c1ece4fa3941 Mon Sep 17 00:00:00 2001 From: Peter <> Date: Thu, 24 Oct 2019 01:01:37 +0400 Subject: [PATCH 3/3] Fix inline bot geo queries --- .../TelegramCore/RequestChatContextResults.swift | 15 +++++++++++++-- .../TelegramCore/TelegramCore/TelegramUser.swift | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) 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)