mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Temp
This commit is contained in:
parent
675696da2b
commit
0aac8d47ac
11 changed files with 197 additions and 19 deletions
|
|
@ -1930,6 +1930,10 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||
self.controller?.verifyAgeCompletion?(Int(ageValue))
|
||||
}
|
||||
}
|
||||
case "web_app_request_chat":
|
||||
if let json, let requestId = json["req_id"] as? String {
|
||||
self.requestChat(requestId: requestId)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
@ -2299,6 +2303,66 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||
})
|
||||
}
|
||||
|
||||
fileprivate func requestChat(requestId: String) {
|
||||
guard let controller = self.controller, !self.dismissed else {
|
||||
return
|
||||
}
|
||||
let _ = (self.context.engine.messages.requestMiniAppButton(peerId: controller.botId, requestId: requestId)
|
||||
|> deliverOnMainQueue).startStandalone(next: { [weak self] button in
|
||||
guard let self, let button else {
|
||||
return
|
||||
}
|
||||
switch button.action {
|
||||
case let .requestPeer(peerType, buttonId, maxQuantity):
|
||||
let _ = maxQuantity
|
||||
|
||||
switch peerType {
|
||||
case let .createBot(createBot):
|
||||
Task { @MainActor [weak self] in
|
||||
guard let self, let controller = self.controller else {
|
||||
return
|
||||
}
|
||||
let createBotScreen = await self.context.sharedContext.makeCreateBotScreen(
|
||||
context: self.context,
|
||||
parentBot: controller.botId,
|
||||
initialUsername: createBot.suggestedUsername,
|
||||
initialTitle: createBot.suggestedName,
|
||||
openAutomatically: false,
|
||||
completion: { [weak self] resultId in
|
||||
guard let self, let controller = self.controller else {
|
||||
return
|
||||
}
|
||||
if let resultId {
|
||||
let _ = self.context.engine.peers.sendBotRequestedPeer(peerId: controller.botId, requestId: requestId, buttonId: buttonId, requestedPeerIds: [resultId]
|
||||
).startStandalone(error: { [weak self] _ in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.webView?.sendEvent(name: "requested_chat_failed", data: nil)
|
||||
}, completed: { [weak self] in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.webView?.sendEvent(name: "requested_chat_sent", data: nil)
|
||||
})
|
||||
} else {
|
||||
self.webView?.sendEvent(name: "requested_chat_failed", data: nil)
|
||||
}
|
||||
}
|
||||
)
|
||||
if let createBotScreen {
|
||||
controller.push(createBotScreen)
|
||||
}
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fileprivate func invokeCustomMethod(requestId: String, method: String, params: String) {
|
||||
guard let controller = self.controller, !self.dismissed else {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue