mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Web app improvements
This commit is contained in:
parent
eb3da67032
commit
f432842f75
@ -9863,6 +9863,8 @@ Sorry for the inconvenience.";
|
|||||||
"Story.ViewList.ViewerCount_any" = "%d Viewers";
|
"Story.ViewList.ViewerCount_any" = "%d Viewers";
|
||||||
|
|
||||||
"AuthSessions.MessageApp" = "You allowed this bot to message you when you opened %@.";
|
"AuthSessions.MessageApp" = "You allowed this bot to message you when you opened %@.";
|
||||||
|
"Notification.BotWriteAllowedMenu" = "You allowed this bot to message you when you added it to your attachment menu.";
|
||||||
|
"Notification.BotWriteAllowedRequest" = "You allowed this bot to message you in the app.";
|
||||||
|
|
||||||
"Story.Privacy.PostStoryAs" = "Post Story As";
|
"Story.Privacy.PostStoryAs" = "Post Story As";
|
||||||
"Story.Privacy.PostStoryAsHeader" = "POST STORY AS";
|
"Story.Privacy.PostStoryAsHeader" = "POST STORY AS";
|
||||||
@ -9892,3 +9894,9 @@ Sorry for the inconvenience.";
|
|||||||
"MediaPicker.Timer.Video.ViewOnceTooltip" = "Video set to view once.";
|
"MediaPicker.Timer.Video.ViewOnceTooltip" = "Video set to view once.";
|
||||||
"MediaPicker.Timer.Video.TimerTooltip" = "Video will be deleted in\n%@ seconds after opening.";
|
"MediaPicker.Timer.Video.TimerTooltip" = "Video will be deleted in\n%@ seconds after opening.";
|
||||||
"MediaPicker.Timer.Video.KeepTooltip" = "Video will be kept in chat.";
|
"MediaPicker.Timer.Video.KeepTooltip" = "Video will be kept in chat.";
|
||||||
|
|
||||||
|
"WebApp.AllowWriteTitle" = "Allow Sending Messages?";
|
||||||
|
"WebApp.AllowWriteConfirmation" = "This will allow the bot **%@** to message you on Telegram.";
|
||||||
|
|
||||||
|
"WebApp.SharePhoneTitle" = "Share Phone Number?";
|
||||||
|
"WebApp.SharePhoneConfirmation" = "**%@** will know your phone number. This can be useful for integration with other services.";
|
||||||
|
@ -53,16 +53,19 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
|||||||
case let .messageActionBotAllowed(flags, domain, app):
|
case let .messageActionBotAllowed(flags, domain, app):
|
||||||
if let domain = domain {
|
if let domain = domain {
|
||||||
return TelegramMediaAction(action: .botDomainAccessGranted(domain: domain))
|
return TelegramMediaAction(action: .botDomainAccessGranted(domain: domain))
|
||||||
} else if case let .botApp(_, _, _, _, appName, _, _, _, _) = app {
|
} else {
|
||||||
|
var appName: String?
|
||||||
|
if case let .botApp(_, _, _, _, appNameValue, _, _, _, _) = app {
|
||||||
|
appName = appNameValue
|
||||||
|
}
|
||||||
var type: BotSendMessageAccessGrantedType?
|
var type: BotSendMessageAccessGrantedType?
|
||||||
if (flags & (1 << 3)) != 0 {
|
if (flags & (1 << 1)) != 0 {
|
||||||
type = .request
|
|
||||||
} else if (flags & (1 << 1)) != 0 {
|
|
||||||
type = .attachMenu
|
type = .attachMenu
|
||||||
}
|
}
|
||||||
|
if (flags & (1 << 3)) != 0 {
|
||||||
|
type = .request
|
||||||
|
}
|
||||||
return TelegramMediaAction(action: .botAppAccessGranted(appName: appName, type: type))
|
return TelegramMediaAction(action: .botAppAccessGranted(appName: appName, type: type))
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
case .messageActionSecureValuesSentMe:
|
case .messageActionSecureValuesSentMe:
|
||||||
return nil
|
return nil
|
||||||
|
@ -91,7 +91,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
case paymentSent(currency: String, totalAmount: Int64, invoiceSlug: String?, isRecurringInit: Bool, isRecurringUsed: Bool)
|
case paymentSent(currency: String, totalAmount: Int64, invoiceSlug: String?, isRecurringInit: Bool, isRecurringUsed: Bool)
|
||||||
case customText(text: String, entities: [MessageTextEntity])
|
case customText(text: String, entities: [MessageTextEntity])
|
||||||
case botDomainAccessGranted(domain: String)
|
case botDomainAccessGranted(domain: String)
|
||||||
case botAppAccessGranted(appName: String, type: BotSendMessageAccessGrantedType?)
|
case botAppAccessGranted(appName: String?, type: BotSendMessageAccessGrantedType?)
|
||||||
case botSentSecureValues(types: [SentSecureValueType])
|
case botSentSecureValues(types: [SentSecureValueType])
|
||||||
case peerJoined
|
case peerJoined
|
||||||
case phoneNumberRequest
|
case phoneNumberRequest
|
||||||
@ -202,7 +202,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
self = .unknown
|
self = .unknown
|
||||||
}
|
}
|
||||||
case 35:
|
case 35:
|
||||||
self = .botAppAccessGranted(appName: decoder.decodeStringForKey("app", orElse: ""), type: decoder.decodeOptionalInt32ForKey("atp").flatMap { BotSendMessageAccessGrantedType(rawValue: $0) })
|
self = .botAppAccessGranted(appName: decoder.decodeOptionalStringForKey("app"), type: decoder.decodeOptionalInt32ForKey("atp").flatMap { BotSendMessageAccessGrantedType(rawValue: $0) })
|
||||||
default:
|
default:
|
||||||
self = .unknown
|
self = .unknown
|
||||||
}
|
}
|
||||||
@ -372,7 +372,11 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
encoder.encode(TelegramWallpaperNativeCodable(wallpaper), forKey: "wallpaper")
|
encoder.encode(TelegramWallpaperNativeCodable(wallpaper), forKey: "wallpaper")
|
||||||
case let .botAppAccessGranted(appName, type):
|
case let .botAppAccessGranted(appName, type):
|
||||||
encoder.encodeInt32(35, forKey: "_rawValue")
|
encoder.encodeInt32(35, forKey: "_rawValue")
|
||||||
|
if let appName = appName {
|
||||||
encoder.encodeString(appName, forKey: "app")
|
encoder.encodeString(appName, forKey: "app")
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: "app")
|
||||||
|
}
|
||||||
if let type = type {
|
if let type = type {
|
||||||
encoder.encodeInt32(type.rawValue, forKey: "atp")
|
encoder.encodeInt32(type.rawValue, forKey: "atp")
|
||||||
} else {
|
} else {
|
||||||
|
@ -629,8 +629,16 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
|||||||
attributedString = stringWithAppliedEntities(text, entities: entities, baseColor: primaryTextColor, linkColor: primaryTextColor, baseFont: titleFont, linkFont: titleBoldFont, boldFont: titleBoldFont, italicFont: titleFont, boldItalicFont: titleBoldFont, fixedFont: titleFont, blockQuoteFont: titleFont, underlineLinks: false, message: message._asMessage())
|
attributedString = stringWithAppliedEntities(text, entities: entities, baseColor: primaryTextColor, linkColor: primaryTextColor, baseFont: titleFont, linkFont: titleBoldFont, boldFont: titleBoldFont, italicFont: titleFont, boldItalicFont: titleBoldFont, fixedFont: titleFont, blockQuoteFont: titleFont, underlineLinks: false, message: message._asMessage())
|
||||||
case let .botDomainAccessGranted(domain):
|
case let .botDomainAccessGranted(domain):
|
||||||
attributedString = NSAttributedString(string: strings.AuthSessions_Message(domain).string, font: titleFont, textColor: primaryTextColor)
|
attributedString = NSAttributedString(string: strings.AuthSessions_Message(domain).string, font: titleFont, textColor: primaryTextColor)
|
||||||
case let .botAppAccessGranted(appName, _):
|
case let .botAppAccessGranted(appName, type):
|
||||||
attributedString = NSAttributedString(string: strings.AuthSessions_MessageApp(appName).string, font: titleFont, textColor: primaryTextColor)
|
let text: String
|
||||||
|
if type == .attachMenu {
|
||||||
|
text = strings.Notification_BotWriteAllowedMenu
|
||||||
|
} else if type == .request {
|
||||||
|
text = strings.Notification_BotWriteAllowedRequest
|
||||||
|
} else {
|
||||||
|
text = strings.AuthSessions_MessageApp(appName ?? "").string
|
||||||
|
}
|
||||||
|
attributedString = NSAttributedString(string: text, font: titleFont, textColor: primaryTextColor)
|
||||||
case let .botSentSecureValues(types):
|
case let .botSentSecureValues(types):
|
||||||
var typesString = ""
|
var typesString = ""
|
||||||
var hasIdentity = false
|
var hasIdentity = false
|
||||||
|
@ -13213,7 +13213,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
|
|
||||||
let buttons: Signal<([AttachmentButtonType], [AttachmentButtonType], AttachmentButtonType?), NoError>
|
let buttons: Signal<([AttachmentButtonType], [AttachmentButtonType], AttachmentButtonType?), NoError>
|
||||||
if !isScheduledMessages {
|
if !isScheduledMessages && !peer.isDeleted {
|
||||||
buttons = self.context.engine.messages.attachMenuBots()
|
buttons = self.context.engine.messages.attachMenuBots()
|
||||||
|> map { attachMenuBots in
|
|> map { attachMenuBots in
|
||||||
var buttons = availableButtons
|
var buttons = availableButtons
|
||||||
|
@ -1104,7 +1104,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
if result {
|
if result {
|
||||||
sendEvent(true)
|
sendEvent(true)
|
||||||
} else {
|
} else {
|
||||||
controller.present(textAlertController(context: self.context, updatedPresentationData: controller.updatedPresentationData, title: "Allow Sending Messages?", text: "Allow \(controller.botName) to send messages?", actions: [TextAlertAction(type: .genericAction, title: self.presentationData.strings.Common_Cancel, action: {
|
controller.present(textAlertController(context: self.context, updatedPresentationData: controller.updatedPresentationData, title: self.presentationData.strings.WebApp_AllowWriteTitle, text: self.presentationData.strings.WebApp_AllowWriteConfirmation(controller.botName).string, actions: [TextAlertAction(type: .genericAction, title: self.presentationData.strings.Common_Cancel, action: {
|
||||||
sendEvent(false)
|
sendEvent(false)
|
||||||
}), TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: { [weak self] in
|
}), TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: { [weak self] in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
@ -1115,16 +1115,17 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
|> deliverOnMainQueue).start(completed: {
|
|> deliverOnMainQueue).start(completed: {
|
||||||
sendEvent(true)
|
sendEvent(true)
|
||||||
})
|
})
|
||||||
})]), in: .window(.root))
|
})], parseMarkdown: true), in: .window(.root))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func shareAccountContact() {
|
fileprivate func shareAccountContact() {
|
||||||
guard let controller = self.controller, let botId = self.controller?.botId else {
|
guard let controller = self.controller, let botId = self.controller?.botId, let botName = self.controller?.botName else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let sendEvent: (Bool) -> Void = { success in
|
let sendEvent: (Bool) -> Void = { success in
|
||||||
var paramsString: String
|
var paramsString: String
|
||||||
if success {
|
if success {
|
||||||
@ -1149,7 +1150,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
requiresUnblock = true
|
requiresUnblock = true
|
||||||
}
|
}
|
||||||
|
|
||||||
let alertController = textAlertController(context: self.context, updatedPresentationData: controller.updatedPresentationData, title: self.presentationData.strings.Conversation_ShareBotContactConfirmationTitle, text: self.presentationData.strings.Conversation_ShareBotContactConfirmation, actions: [TextAlertAction(type: .genericAction, title: self.presentationData.strings.Common_Cancel, action: {
|
let alertController = textAlertController(context: self.context, updatedPresentationData: controller.updatedPresentationData, title: self.presentationData.strings.WebApp_SharePhoneTitle, text: self.presentationData.strings.WebApp_SharePhoneConfirmation(botName).string, actions: [TextAlertAction(type: .genericAction, title: self.presentationData.strings.Common_Cancel, action: {
|
||||||
sendEvent(false)
|
sendEvent(false)
|
||||||
}), TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: { [weak self] in
|
}), TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: { [weak self] in
|
||||||
guard let self, case let .user(user) = accountPeer, let phone = user.phone, !phone.isEmpty else {
|
guard let self, case let .user(user) = accountPeer, let phone = user.phone, !phone.isEmpty else {
|
||||||
@ -1190,7 +1191,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
} else {
|
} else {
|
||||||
sendMessage()
|
sendMessage()
|
||||||
}
|
}
|
||||||
})])
|
})], parseMarkdown: true)
|
||||||
alertController.dismissed = { byOutsideTap in
|
alertController.dismissed = { byOutsideTap in
|
||||||
if byOutsideTap {
|
if byOutsideTap {
|
||||||
sendEvent(false)
|
sendEvent(false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user