mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add webapp test
This commit is contained in:
parent
ad35281263
commit
ff306b0f89
@ -65,7 +65,6 @@ public enum ChatOpenWebViewSource: Equatable {
|
||||
case generic
|
||||
case menu
|
||||
case inline(bot: EnginePeer)
|
||||
case webApp(botApp: BotApp)
|
||||
}
|
||||
|
||||
public final class ChatPanelInterfaceInteraction {
|
||||
|
@ -346,8 +346,6 @@ public extension ChatControllerImpl {
|
||||
}
|
||||
self.attachmentController?.dismiss(animated: true, completion: nil)
|
||||
|
||||
|
||||
|
||||
let openBotApp: (Bool, Bool) -> Void = { [weak self] allowWrite, justInstalled in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
|
@ -326,12 +326,15 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
guard let controller = self.controller else {
|
||||
return
|
||||
}
|
||||
|
||||
if let url = controller.url, controller.source != .menu {
|
||||
self.queryId = controller.queryId
|
||||
if let parsedUrl = URL(string: url) {
|
||||
self.webView?.load(URLRequest(url: parsedUrl))
|
||||
}
|
||||
|
||||
self.checkBotIdAndUrl(url)
|
||||
|
||||
if let keepAliveSignal = controller.keepAliveSignal {
|
||||
self.keepAliveDisposable = (keepAliveSignal
|
||||
|> deliverOnMainQueue).start(error: { [weak self] _ in
|
||||
@ -351,6 +354,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.checkBotIdAndUrl(result.url)
|
||||
if let parsedUrl = URL(string: result.url) {
|
||||
strongSelf.queryId = result.queryId
|
||||
strongSelf.webView?.load(URLRequest(url: parsedUrl))
|
||||
@ -372,6 +376,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
guard let self, let parsedUrl = URL(string: result.url) else {
|
||||
return
|
||||
}
|
||||
self.checkBotIdAndUrl(result.url)
|
||||
self.controller?.titleView?.title = WebAppTitle(title: appStart.botApp.title, counter: self.presentationData.strings.WebApp_Miniapp, isVerified: controller.botVerified)
|
||||
self.webView?.load(URLRequest(url: parsedUrl))
|
||||
})
|
||||
@ -385,6 +390,8 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
strongSelf.queryId = result.queryId
|
||||
strongSelf.webView?.load(URLRequest(url: parsedUrl))
|
||||
|
||||
strongSelf.checkBotIdAndUrl(result.url)
|
||||
|
||||
if let keepAliveSignal = result.keepAliveSignal {
|
||||
strongSelf.keepAliveDisposable = (keepAliveSignal
|
||||
|> deliverOnMainQueue).start(error: { [weak self] _ in
|
||||
@ -404,6 +411,15 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
}
|
||||
}
|
||||
|
||||
func checkBotIdAndUrl(_ url: String) {
|
||||
//1985737506
|
||||
if url.hasPrefix("https://walletbot.me"), let botId = self.controller?.botId.id._internalGetInt64Value(), botId != 1985737506 {
|
||||
let alertController = textAlertController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, title: nil, text: "Bot id mismatch, please report steps to app developer", actions: [TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: {
|
||||
})])
|
||||
self.controller?.present(alertController, in: .window(.root))
|
||||
}
|
||||
}
|
||||
|
||||
@objc fileprivate func mainButtonPressed() {
|
||||
if let mainButtonState = self.mainButtonState, !mainButtonState.isVisible || !mainButtonState.isEnabled {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user