diff --git a/submodules/TelegramCore/Sources/ApiUtils/BotInfo.swift b/submodules/TelegramCore/Sources/ApiUtils/BotInfo.swift index 84d41311e9..b12c38fa1b 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/BotInfo.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/BotInfo.swift @@ -31,11 +31,12 @@ extension BotAppSettings { extension BotVerifierSettings { init(apiBotVerifierSettings: Api.BotVerifierSettings) { switch apiBotVerifierSettings { - case let .botVerifierSettings(_, iconFileId, companyName, customDescription): + case let .botVerifierSettings(flags, iconFileId, companyName, customDescription): self.init( iconFileId: iconFileId, companyName: companyName, - customDescription: customDescription + customDescription: customDescription, + canModifyDescription: (flags & (1 << 1)) != 0 ) } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_BotInfo.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_BotInfo.swift index c7f0d44fcb..8226e7ba9c 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_BotInfo.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_BotInfo.swift @@ -102,17 +102,20 @@ public struct BotVerifierSettings: PostboxCoding, Equatable { public let iconFileId: Int64 public let companyName: String public let customDescription: String? + public let canModifyDescription: Bool - public init(iconFileId: Int64, companyName: String, customDescription: String?) { + public init(iconFileId: Int64, companyName: String, customDescription: String?, canModifyDescription: Bool) { self.iconFileId = iconFileId self.companyName = companyName self.customDescription = customDescription + self.canModifyDescription = canModifyDescription } public init(decoder: PostboxDecoder) { self.iconFileId = decoder.decodeInt64ForKey("i", orElse: 0) self.companyName = decoder.decodeStringForKey("cn", orElse: "") self.customDescription = decoder.decodeOptionalStringForKey("d") + self.canModifyDescription = decoder.decodeBoolForKey("md", orElse: false) } public func encode(_ encoder: PostboxEncoder) { @@ -123,6 +126,7 @@ public struct BotVerifierSettings: PostboxCoding, Equatable { } else { encoder.encodeNil(forKey: "d") } + encoder.encodeBool(self.canModifyDescription, forKey: "md") } } diff --git a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChatList.swift b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChatList.swift index ac0ec604d1..9522c0706a 100644 --- a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChatList.swift +++ b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChatList.swift @@ -268,11 +268,11 @@ public struct PresentationResourcesChatList { public static func locationIcon(_ theme: PresentationTheme) -> UIImage? { return theme.image(PresentationResourceKey.chatListLocationIcon.rawValue, { theme in if let image = UIImage(bundleImageName: "Chat/Attach Menu/Location") { - return generateImage(image.size, contextGenerator: { size, context in + return generateImage(CGSize(width: 20.0, height: 20.0), contextGenerator: { size, context in if let cgImage = image.cgImage { context.clear(CGRect(origin: CGPoint(), size: size)) - context.clip(to: CGRect(origin: .zero, size: size).insetBy(dx: 5.0, dy: 5.0), mask: cgImage) + context.clip(to: CGRect(origin: .zero, size: size), mask: cgImage) context.setFillColor(theme.chatList.muteIconColor.cgColor) context.fill(CGRect(origin: CGPoint(), size: size)) } diff --git a/submodules/TelegramUI/Components/PeerInfo/VerifyAlertController/Sources/VerifyAlertController.swift b/submodules/TelegramUI/Components/PeerInfo/VerifyAlertController/Sources/VerifyAlertController.swift index 71e9066557..57b81e1ac6 100644 --- a/submodules/TelegramUI/Components/PeerInfo/VerifyAlertController/Sources/VerifyAlertController.swift +++ b/submodules/TelegramUI/Components/PeerInfo/VerifyAlertController/Sources/VerifyAlertController.swift @@ -413,7 +413,7 @@ public func verifyAlertController(context: AccountContext, updatedPresentationDa })] //TODO:localize - let contentNode = VerifyAlertContentNode(context: context, theme: AlertControllerTheme(presentationData: presentationData), presentationTheme: presentationData.theme, strings: presentationData.strings, actions: actions, title: "Verify Account", text: "Do you want to verify this account with your verification mark and description?", peer: peer, verifierSettings: verifierSettings, verifierIcon: verifierIcon, hasInput: true) + let contentNode = VerifyAlertContentNode(context: context, theme: AlertControllerTheme(presentationData: presentationData), presentationTheme: presentationData.theme, strings: presentationData.strings, actions: actions, title: "Verify Account", text: "Do you want to verify this account with your verification mark and description?", peer: peer, verifierSettings: verifierSettings, verifierIcon: verifierIcon, hasInput: verifierSettings.canModifyDescription) contentNode.complete = { applyImpl?() } diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenWebApp.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenWebApp.swift index ece5f7b4cf..3477609073 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerOpenWebApp.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerOpenWebApp.swift @@ -452,7 +452,7 @@ public extension ChatControllerImpl { self.attachmentController?.dismiss(animated: true, completion: nil) if let botApp { - let openBotApp: (Bool, Bool) -> Void = { [weak self] allowWrite, justInstalled in + let openBotApp: (Bool, Bool, BotAppSettings?) -> Void = { [weak self] allowWrite, justInstalled, appSettings in guard let strongSelf = self else { return } @@ -510,7 +510,7 @@ public extension ChatControllerImpl { return } let context = strongSelf.context - let params = WebAppParameters(source: .generic, peerId: peerId, botId: botPeer.id, botName: botApp.title, botVerified: botPeer.isVerified, botAddress: botPeer.addressName ?? "", appName: botApp.shortName, url: result.url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, forceHasSettings: botApp.flags.contains(.hasSettings), fullSize: result.flags.contains(.fullSize), isFullscreen: result.flags.contains(.fullScreen), appSettings: nil) + let params = WebAppParameters(source: .generic, peerId: peerId, botId: botPeer.id, botName: botApp.title, botVerified: botPeer.isVerified, botAddress: botPeer.addressName ?? "", appName: botApp.shortName, url: result.url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, forceHasSettings: botApp.flags.contains(.hasSettings), fullSize: result.flags.contains(.fullSize), isFullscreen: result.flags.contains(.fullScreen), appSettings: appSettings) var presentImpl: ((ViewController, Any?) -> Void)? let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, forceUpdate, commit in ChatControllerImpl.botOpenUrl(context: context, peerId: peerId, controller: self, url: url, concealed: concealed, forceUpdate: forceUpdate, present: { c, a in @@ -551,8 +551,9 @@ public extension ChatControllerImpl { |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) - } - ).startStandalone(next: { [weak self] noticed, attachMenuBots, attachMenuBot in + }, + self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.BotAppSettings(id: botPeer.id)) + ).startStandalone(next: { [weak self] noticed, attachMenuBots, attachMenuBot, appSettings in guard let self else { return } @@ -575,17 +576,17 @@ public extension ChatControllerImpl { let _ = (context.engine.messages.addBotToAttachMenu(botId: botPeer.id, allowWrite: allowWrite) |> deliverOnMainQueue).startStandalone(error: { _ in }, completed: { - openBotApp(allowWrite, true) + openBotApp(allowWrite, true, appSettings) }) }) self.present(controller, in: .window(.root)) } else { - openBotApp(false, false) + openBotApp(false, false, appSettings) } } else { let controller = webAppLaunchConfirmationController(context: context, updatedPresentationData: self.updatedPresentationData, peer: botPeer, requestWriteAccess: botApp.flags.contains(.notActivated) && botApp.flags.contains(.requiresWriteAccess), completion: { allowWrite in let _ = ApplicationSpecificNotice.setBotGameNotice(accountManager: context.sharedContext.accountManager, peerId: botPeer.id).startStandalone() - openBotApp(allowWrite, false) + openBotApp(allowWrite, false, appSettings) }, showMore: { [weak self] in if let self { self.openResolved(result: .peer(botPeer._asPeer(), .info(nil)), sourceMessageId: nil) @@ -598,7 +599,7 @@ public extension ChatControllerImpl { self.present(controller, in: .window(.root)) } } else { - openBotApp(false, false) + openBotApp(false, false, appSettings) } }) } else {