Update API

This commit is contained in:
Ilya Laktyushin 2024-04-15 16:39:53 +04:00
parent 78b0c5f509
commit 231d8f0808
21 changed files with 1379 additions and 1050 deletions

View File

@ -12052,3 +12052,28 @@ Sorry for the inconvenience.";
"Premium.Gift.ContactSelection.SendMessage" = "Send Message"; "Premium.Gift.ContactSelection.SendMessage" = "Send Message";
"Premium.Gift.ContactSelection.OpenProfile" = "Open Profile"; "Premium.Gift.ContactSelection.OpenProfile" = "Open Profile";
"Login.EnterWordTitle" = "Enter Word";
"Login.EnterWordText" = "We've sent you an SMS with a secret word to your phone **%@**.";
"Login.EnterWordBeginningText" = "We've sent you an SMS with a secret word that starts with **\"%1$@\"** to your phone **%2$@**.";
"Login.EnterWordPlaceholder" = "Enter Word from SMS";
"Login.EnterPhraseTitle" = "Enter Phrase";
"Login.EnterPhraseText" = "We've sent you an SMS with a secret phrase to your phone **%@**.";
"Login.EnterPhraseBeginningText" = "We've sent you an SMS with a secret phrase that starts with **\"%1$@\"** to your phone **%2$@**.";
"Login.EnterPhrasePlaceholder" = "Enter Phrase from SMS";
"Login.WrongPhraseError" = "Incorrect, please try again.";
"Map.LiveLocationPrivateNewDescription" = "Choose for how long **%@** will see your accurate location, including when the app is closed.";
"Map.LiveLocationGroupNewDescription" = "Choose for how long people in this chat will see your accurate location, including when the app is closed.";
"Map.LiveLocationExtendDescription" = "For how long do you want to extend sharing your location?";
"Map.LiveLocationForMinutes_1" = "For %@ minute";
"Map.LiveLocationForMinutes_any" = "For %@ minutes";
"Map.LiveLocationForHours_1" = "For %@ hour";
"Map.LiveLocationForHours_any" = "For %@ hours";
"Map.LiveLocationIndefinite" = "Until I turn it off";

View File

@ -220,7 +220,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
minimalCodeLength = Int(length) minimalCodeLength = Int(length)
case let .firebase(_, length): case let .firebase(_, length):
minimalCodeLength = Int(length) minimalCodeLength = Int(length)
case .flashCall, .emailSetupRequired: case .flashCall, .emailSetupRequired, .word, .phrase:
break break
} }

View File

@ -39,6 +39,9 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
private var signInWithAppleButton: UIControl? private var signInWithAppleButton: UIControl?
private let proceedNode: SolidRoundedButtonNode private let proceedNode: SolidRoundedButtonNode
private let textField: TextFieldNode
private let textSeparatorNode: ASDisplayNode
private let codeInputView: CodeInputView private let codeInputView: CodeInputView
private let errorTextNode: ImmediateTextNode private let errorTextNode: ImmediateTextNode
@ -64,8 +67,13 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
var email: String? var email: String?
var currentCode: String { var currentCode: String {
switch self.codeType {
case .word, .phrase:
return self.textField.textField.text ?? ""
default:
return self.codeInputView.text return self.codeInputView.text
} }
}
var loginWithCode: ((String) -> Void)? var loginWithCode: ((String) -> Void)?
var signInWithApple: (() -> Void)? var signInWithApple: (() -> Void)?
@ -81,6 +89,19 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
var inProgress: Bool = false { var inProgress: Bool = false {
didSet { didSet {
self.codeInputView.alpha = self.inProgress ? 0.6 : 1.0 self.codeInputView.alpha = self.inProgress ? 0.6 : 1.0
switch self.codeType {
case .word, .phrase:
if self.inProgress != oldValue {
if self.inProgress {
self.proceedNode.transitionToProgress()
} else {
self.proceedNode.transitionFromProgress()
}
}
default:
break
}
} }
} }
@ -151,6 +172,28 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.codeInputView.textField.keyboardType = .numberPad self.codeInputView.textField.keyboardType = .numberPad
} }
self.textSeparatorNode = ASDisplayNode()
self.textSeparatorNode.isLayerBacked = true
self.textSeparatorNode.backgroundColor = self.theme.list.itemPlainSeparatorColor
self.textField = TextFieldNode()
self.textField.textField.font = Font.regular(20.0)
self.textField.textField.textColor = self.theme.list.itemPrimaryTextColor
self.textField.textField.textAlignment = .natural
self.textField.textField.autocorrectionType = .yes
self.textField.textField.autocorrectionType = .no
self.textField.textField.spellCheckingType = .yes
self.textField.textField.spellCheckingType = .no
self.textField.textField.autocapitalizationType = .none
self.textField.textField.keyboardType = .default
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
self.textField.textField.textContentType = UITextContentType(rawValue: "")
}
self.textField.textField.returnKeyType = .default
self.textField.textField.keyboardAppearance = self.theme.rootController.keyboardColor.keyboardAppearance
self.textField.textField.disableAutomaticKeyboardHandling = [.forward, .backward]
self.textField.textField.tintColor = self.theme.list.itemAccentColor
self.errorTextNode = ImmediateTextNode() self.errorTextNode = ImmediateTextNode()
self.errorTextNode.alpha = 0.0 self.errorTextNode.alpha = 0.0
self.errorTextNode.displaysAsynchronously = false self.errorTextNode.displaysAsynchronously = false
@ -175,11 +218,12 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.signInWithAppleButton?.isHidden = true self.signInWithAppleButton?.isHidden = true
(self.signInWithAppleButton as? ASAuthorizationAppleIDButton)?.cornerRadius = 11 (self.signInWithAppleButton as? ASAuthorizationAppleIDButton)?.cornerRadius = 11
} }
self.proceedNode = SolidRoundedButtonNode(title: self.strings.Login_OpenFragment, theme: SolidRoundedButtonTheme(backgroundColor: UIColor(rgb: 0x37475a), foregroundColor: .white), height: 50.0, cornerRadius: 11.0, gloss: false) self.proceedNode = SolidRoundedButtonNode(title: self.strings.Login_Continue, theme: SolidRoundedButtonTheme(theme: self.theme), height: 50.0, cornerRadius: 11.0, gloss: false)
self.proceedNode.progressType = .embedded self.proceedNode.progressType = .embedded
self.proceedNode.isHidden = true self.proceedNode.isHidden = true
self.proceedNode.iconSpacing = 4.0 self.proceedNode.iconSpacing = 4.0
self.proceedNode.animationSize = CGSize(width: 36.0, height: 36.0) self.proceedNode.animationSize = CGSize(width: 36.0, height: 36.0)
self.proceedNode.isEnabled = false
super.init() super.init()
@ -189,7 +233,11 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.backgroundColor = self.theme.list.plainBackgroundColor self.backgroundColor = self.theme.list.plainBackgroundColor
self.textField.textField.delegate = self
self.addSubnode(self.codeInputView) self.addSubnode(self.codeInputView)
self.addSubnode(self.textSeparatorNode)
self.addSubnode(self.textField)
self.addSubnode(self.titleNode) self.addSubnode(self.titleNode)
self.addSubnode(self.titleActivateAreaNode) self.addSubnode(self.titleActivateAreaNode)
self.addSubnode(self.titleIconNode) self.addSubnode(self.titleIconNode)
@ -208,9 +256,11 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
strongSelf.textChanged(text: strongSelf.codeInputView.text) strongSelf.codeChanged(text: strongSelf.codeInputView.text)
} }
self.textField.textField.addTarget(self, action: #selector(self.textDidChange), for: .editingChanged)
self.codeInputView.longPressed = { [weak self] in self.codeInputView.longPressed = { [weak self] in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
@ -261,7 +311,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
func updateCode(_ code: String) { func updateCode(_ code: String) {
self.codeInputView.text = code self.codeInputView.text = code
self.textChanged(text: code) self.codeChanged(text: code)
if let codeLength = self.requiredCodeLength, code.count == Int(codeLength) { if let codeLength = self.requiredCodeLength, code.count == Int(codeLength) {
self.loginWithCode?(code) self.loginWithCode?(code)
@ -401,6 +451,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
var animationName = "IntroMessage" var animationName = "IntroMessage"
var animationPlaybackMode: AnimatedStickerPlaybackMode = .once var animationPlaybackMode: AnimatedStickerPlaybackMode = .once
var textFieldPlaceholder = ""
if let codeType = self.codeType { if let codeType = self.codeType {
switch codeType { switch codeType {
case .missedCall: case .missedCall:
@ -412,9 +463,20 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterCodeSMSTitle, font: Font.semibold(28.0), textColor: self.theme.list.itemPrimaryTextColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterCodeSMSTitle, font: Font.semibold(28.0), textColor: self.theme.list.itemPrimaryTextColor)
case .fragment: case .fragment:
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterCodeFragmentTitle, font: Font.semibold(28.0), textColor: self.theme.list.itemPrimaryTextColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterCodeFragmentTitle, font: Font.semibold(28.0), textColor: self.theme.list.itemPrimaryTextColor)
self.proceedNode.title = self.strings.Login_OpenFragment
self.proceedNode.updateTheme(SolidRoundedButtonTheme(backgroundColor: UIColor(rgb: 0x37475a), foregroundColor: .white))
self.proceedNode.isEnabled = true
animationName = "IntroFragment" animationName = "IntroFragment"
animationPlaybackMode = .count(3) animationPlaybackMode = .count(3)
self.proceedNode.animation = "anim_fragment" self.proceedNode.animation = "anim_fragment"
case .word:
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterWordTitle, font: Font.semibold(28.0), textColor: self.theme.list.itemPrimaryTextColor)
textFieldPlaceholder = self.strings.Login_EnterWordPlaceholder
case .phrase:
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterPhraseTitle, font: Font.semibold(28.0), textColor: self.theme.list.itemPrimaryTextColor)
textFieldPlaceholder = self.strings.Login_EnterPhrasePlaceholder
default: default:
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterCodeTelegramTitle, font: Font.semibold(28.0), textColor: self.theme.list.itemPrimaryTextColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterCodeTelegramTitle, font: Font.semibold(28.0), textColor: self.theme.list.itemPrimaryTextColor)
} }
@ -422,14 +484,17 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterCodeTelegramTitle, font: Font.semibold(40.0), textColor: self.theme.list.itemPrimaryTextColor) self.titleNode.attributedText = NSAttributedString(string: self.strings.Login_EnterCodeTelegramTitle, font: Font.semibold(40.0), textColor: self.theme.list.itemPrimaryTextColor)
} }
self.textField.textField.placeholder = textFieldPlaceholder
self.titleActivateAreaNode.accessibilityLabel = self.titleNode.attributedText?.string ?? "" self.titleActivateAreaNode.accessibilityLabel = self.titleNode.attributedText?.string ?? ""
if let inputHeight = layout.inputHeight { if let inputHeight = layout.inputHeight {
if let codeType = self.codeType, case .email = codeType { switch self.codeType {
case .email, .fragment:
insets.bottom = max(inputHeight, insets.bottom) insets.bottom = max(inputHeight, insets.bottom)
} else if let codeType = self.codeType, case .fragment = codeType { case .word, .phrase:
insets.bottom = max(inputHeight, insets.bottom) insets.bottom = max(inputHeight, layout.standardKeyboardHeight)
} else { default:
insets.bottom = max(inputHeight, layout.standardInputHeight) insets.bottom = max(inputHeight, layout.standardInputHeight)
} }
} }
@ -475,6 +540,8 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
codeLength = Int(length) codeLength = Int(length)
case .emailSetupRequired: case .emailSetupRequired:
codeLength = 6 codeLength = 6
case .word, .phrase:
codeLength = 0
case .none: case .none:
codeLength = 6 codeLength = 6
} }
@ -498,8 +565,11 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
if layout.size.width > 320.0 { if layout.size.width > 320.0 {
items.append(AuthorizationLayoutItem(node: self.animationNode, size: animationSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 10.0, maxValue: 10.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0))) items.append(AuthorizationLayoutItem(node: self.animationNode, size: animationSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 10.0, maxValue: 10.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)))
self.animationNode.updateLayout(size: animationSize) self.animationNode.updateLayout(size: animationSize)
self.animationNode.isHidden = false
self.animationNode.visibility = true
} else { } else {
insets.top = navigationBarHeight insets.top = navigationBarHeight
self.animationNode.isHidden = true
} }
var additionalBottomInset: CGFloat = 20.0 var additionalBottomInset: CGFloat = 20.0
@ -550,7 +620,19 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
} }
} }
switch codeType {
case .word, .phrase:
self.codeInputView.isHidden = true
self.textField.isHidden = false
self.textSeparatorNode.isHidden = false
items.append(AuthorizationLayoutItem(node: self.textField, size: CGSize(width: maximumWidth - 88.0, height: 44.0), spacingBefore: AuthorizationLayoutItemSpacing(weight: 18.0, maxValue: 30.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)))
items.append(AuthorizationLayoutItem(node: self.textSeparatorNode, size: CGSize(width: maximumWidth - 48.0, height: UIScreenPixel), spacingBefore: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)))
default:
self.codeInputView.isHidden = false
self.textField.isHidden = true
self.textSeparatorNode.isHidden = true
items.append(AuthorizationLayoutItem(node: self.codeInputView, size: codeFieldSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 30.0, maxValue: 30.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: canReset || pendingDate != nil ? 0.0 : 104.0, maxValue: canReset ? 0.0 : 104.0))) items.append(AuthorizationLayoutItem(node: self.codeInputView, size: codeFieldSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 30.0, maxValue: 30.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: canReset || pendingDate != nil ? 0.0 : 104.0, maxValue: canReset ? 0.0 : 104.0)))
}
if canReset { if canReset {
self.resetNode.setAttributedTitle(NSAttributedString(string: self.strings.Login_Email_CantAccess, font: Font.regular(17.0), textColor: self.theme.list.itemAccentColor, paragraphAlignment: .center), for: []) self.resetNode.setAttributedTitle(NSAttributedString(string: self.strings.Login_Email_CantAccess, font: Font.regular(17.0), textColor: self.theme.list.itemAccentColor, paragraphAlignment: .center), for: [])
@ -614,7 +696,29 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
} else { } else {
self.signInWithAppleButton?.isHidden = true self.signInWithAppleButton?.isHidden = true
self.dividerNode.isHidden = true self.dividerNode.isHidden = true
switch codeType {
case .word, .phrase:
additionalBottomInset = 120.0
self.nextOptionButtonNode.isHidden = false
items.append(AuthorizationLayoutItem(node: self.nextOptionButtonNode, size: nextOptionSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 50.0, maxValue: 120.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)))
if layout.size.width > 320.0 {
self.proceedNode.isHidden = false
} else {
self.proceedNode.isHidden = true self.proceedNode.isHidden = true
}
let buttonFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((layout.size.width - proceedSize.width) / 2.0), y: layout.size.height - insets.bottom - proceedSize.height - inset), size: proceedSize)
transition.updateFrame(node: self.proceedNode, frame: buttonFrame)
case .email:
self.nextOptionButtonNode.isHidden = true
self.proceedNode.isHidden = true
default:
self.nextOptionButtonNode.isHidden = false
self.proceedNode.isHidden = true
items.append(AuthorizationLayoutItem(node: self.nextOptionButtonNode, size: nextOptionSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 50.0, maxValue: 120.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0)))
}
if case .email = codeType { if case .email = codeType {
self.nextOptionButtonNode.isHidden = true self.nextOptionButtonNode.isHidden = true
@ -644,31 +748,58 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
} }
func activateInput() { func activateInput() {
switch self.codeType {
case .word, .phrase:
self.textField.textField.becomeFirstResponder()
default:
let _ = self.codeInputView.becomeFirstResponder() let _ = self.codeInputView.becomeFirstResponder()
} }
}
func animateError() { func animateError() {
switch self.codeType {
case .word, .phrase:
self.textField.layer.addShakeAnimation()
default:
self.codeInputView.layer.addShakeAnimation() self.codeInputView.layer.addShakeAnimation()
} }
}
func animateError(text: String) { func animateError(text: String) {
let errorOriginY: CGFloat
let errorOriginOffset: CGFloat
switch self.codeType {
case .word, .phrase:
self.textField.layer.addShakeAnimation()
let transition: ContainedViewLayoutTransition = .animated(duration: 0.15, curve: .easeInOut)
transition.updateBackgroundColor(node: self.textSeparatorNode, color: self.theme.list.itemDestructiveColor)
errorOriginY = self.textField.frame.maxY
errorOriginOffset = 5.0
default:
self.codeInputView.animateError() self.codeInputView.animateError()
self.codeInputView.layer.addShakeAnimation(amplitude: -30.0, duration: 0.5, count: 6, decay: true) self.codeInputView.layer.addShakeAnimation(amplitude: -30.0, duration: 0.5, count: 6, decay: true)
errorOriginY = self.codeInputView.frame.maxY
errorOriginOffset = 11.0
}
self.errorTextNode.attributedText = NSAttributedString(string: text, font: Font.regular(17.0), textColor: self.theme.list.itemDestructiveColor, paragraphAlignment: .center) self.errorTextNode.attributedText = NSAttributedString(string: text, font: Font.regular(13.0), textColor: self.theme.list.itemDestructiveColor, paragraphAlignment: .center)
if let (layout, _) = self.layoutArguments { if let (layout, _) = self.layoutArguments {
let errorTextSize = self.errorTextNode.updateLayout(CGSize(width: layout.size.width - 48.0, height: .greatestFiniteMagnitude)) let errorTextSize = self.errorTextNode.updateLayout(CGSize(width: layout.size.width - 48.0, height: .greatestFiniteMagnitude))
let yOffset: CGFloat = layout.size.width > 320.0 ? 28.0 : 15.0 let yOffset: CGFloat = layout.size.width > 320.0 ? errorOriginOffset + 13.0 : errorOriginOffset
self.errorTextNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layout.size.width - errorTextSize.width) / 2.0), y: self.codeInputView.frame.maxY + yOffset), size: errorTextSize) self.errorTextNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layout.size.width - errorTextSize.width) / 2.0), y: errorOriginY + yOffset), size: errorTextSize)
} }
self.errorTextNode.alpha = 1.0 self.errorTextNode.alpha = 1.0
self.errorTextNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15) self.errorTextNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15)
self.errorTextNode.layer.addShakeAnimation(amplitude: -8.0, duration: 0.5, count: 6, decay: true) self.errorTextNode.layer.addShakeAnimation(amplitude: -8.0, duration: 0.5, count: 6, decay: true)
Queue.mainQueue().after(0.85) { Queue.mainQueue().after(1.6) {
self.errorTextNode.alpha = 0.0 self.errorTextNode.alpha = 0.0
self.errorTextNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15) self.errorTextNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15)
let transition: ContainedViewLayoutTransition = .animated(duration: 0.15, curve: .easeInOut)
transition.updateBackgroundColor(node: self.textSeparatorNode, color: self.theme.list.itemPlainSeparatorColor)
} }
} }
@ -679,11 +810,13 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.codeInputView.layer.animateKeyframes(values: values, duration: 0.4, keyPath: "transform.scale") self.codeInputView.layer.animateKeyframes(values: values, duration: 0.4, keyPath: "transform.scale")
} }
@objc func codeFieldTextChanged(_ textField: UITextField) { @objc private func textDidChange() {
self.textChanged(text: textField.text ?? "") let text = self.textField.textField.text ?? ""
self.proceedNode.isEnabled = !text.isEmpty
self.updateNextEnabled?(!text.isEmpty)
} }
private func textChanged(text: String) { private func codeChanged(text: String) {
self.updateNextEnabled?(!text.isEmpty) self.updateNextEnabled?(!text.isEmpty)
if let codeType = self.codeType { if let codeType = self.codeType {
var codeLength: Int32? var codeLength: Int32?
@ -715,20 +848,36 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
if self.inProgress { if self.inProgress {
return false return false
} }
var result = ""
for c in string { var updated = textField.text ?? ""
if c.unicodeScalars.count == 1 { updated.replaceSubrange(updated.index(updated.startIndex, offsetBy: range.lowerBound) ..< updated.index(updated.startIndex, offsetBy: range.upperBound), with: string)
let scalar = c.unicodeScalars.first!
if scalar >= "0" && scalar <= "9" { if let codeType = self.codeType {
result.append(c) switch codeType {
case let .word(startsWith):
if let startsWith, startsWith.count == 1, !updated.isEmpty && !updated.hasPrefix(startsWith) {
if self.errorTextNode.alpha.isZero {
//TODO:localize
self.animateError(text: "Incorrect, please try again")
} }
}
}
if result != string {
textField.text = result
self.codeFieldTextChanged(textField)
return false return false
} }
case let .phrase(startsWith):
if let startsWith, !updated.isEmpty {
let firstWord = updated.components(separatedBy: " ").first ?? ""
if !firstWord.isEmpty && !startsWith.hasPrefix(firstWord) {
if self.errorTextNode.alpha.isZero {
//TODO:localize
self.animateError(text: "Incorrect, please try again")
}
return false
}
}
default:
break
}
}
return true return true
} }
@ -737,8 +886,15 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
} }
@objc func proceedPressed() { @objc func proceedPressed() {
if case let .fragment(url, _) = self.codeType { switch self.codeType {
case let .fragment(url, _):
self.openFragment?(url) self.openFragment?(url)
case .word, .phrase:
if let text = self.textField.textField.text, !text.isEmpty {
self.loginWithCode?(text)
}
default:
break
} }
} }

View File

@ -54,6 +54,10 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
} }
private var didSetReady = false private var didSetReady = false
fileprivate var engine: TelegramEngineUnauthorized {
return TelegramEngineUnauthorized(account: self.account)
}
public init(sharedContext: SharedAccountContext, account: UnauthorizedAccount, otherAccountPhoneNumbers: ((String, AccountRecordId, Bool)?, [(String, AccountRecordId, Bool)]), presentationData: PresentationData, openUrl: @escaping (String) -> Void, apiId: Int32, apiHash: String, authorizationCompleted: @escaping () -> Void) { public init(sharedContext: SharedAccountContext, account: UnauthorizedAccount, otherAccountPhoneNumbers: ((String, AccountRecordId, Bool)?, [(String, AccountRecordId, Bool)]), presentationData: PresentationData, openUrl: @escaping (String) -> Void, apiId: Int32, apiHash: String, authorizationCompleted: @escaping () -> Void) {
self.sharedContext = sharedContext self.sharedContext = sharedContext
self.account = account self.account = account
@ -74,7 +78,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
super.init(mode: .single, theme: NavigationControllerTheme(statusBar: navigationStatusBar, navigationBar: AuthorizationSequenceController.navigationBarTheme(presentationData.theme), emptyAreaColor: .black), isFlat: true) super.init(mode: .single, theme: NavigationControllerTheme(statusBar: navigationStatusBar, navigationBar: AuthorizationSequenceController.navigationBarTheme(presentationData.theme), emptyAreaColor: .black), isFlat: true)
self.stateDisposable = (TelegramEngineUnauthorized(account: self.account).auth.state() self.stateDisposable = (self.engine.auth.state()
|> map { state -> InnerState in |> map { state -> InnerState in
if case .authorized = state { if case .authorized = state {
return .authorized return .authorized
@ -127,7 +131,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
let countryCode = AuthorizationSequenceController.defaultCountryCode() let countryCode = AuthorizationSequenceController.defaultCountryCode()
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: isTestingEnvironment, masterDatacenterId: masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: isTestingEnvironment, masterDatacenterId: masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone()
} }
} }
} }
@ -157,7 +161,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
transaction.removeAuth() transaction.removeAuth()
}).startStandalone() }).startStandalone()
} else { } else {
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .empty)).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .empty)).startStandalone()
} }
}) })
if let splashController = splashController { if let splashController = splashController {
@ -299,9 +303,6 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
if c.data?.2 == type { if c.data?.2 == type {
currentController = c currentController = c
} }
// else if case let .email(_, _, _, newPendingDate, _, _) = type, let previousType = c.data?.2, case let .email(_, _, _, previousPendingDate, _, _) = previousType, newPendingDate != nil && previousPendingDate == nil {
// currentController = c
// }
break break
} }
} }
@ -315,7 +316,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
} }
let countryCode = AuthorizationSequenceController.defaultCountryCode() let countryCode = AuthorizationSequenceController.defaultCountryCode()
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone()
}) })
controller.retryResetEmail = { [weak self] in controller.retryResetEmail = { [weak self] in
if let self { if let self {
@ -381,7 +382,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
case .codeExpired: case .codeExpired:
text = self.presentationData.strings.Login_CodeExpired text = self.presentationData.strings.Login_CodeExpired
let account = self.account let account = self.account
let _ = TelegramEngineUnauthorized(account: self.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone() let _ = self.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone()
} }
controller.presentInGlobalOverlay(standardTextAlertController(theme: AlertControllerTheme(presentationData: self.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: {})])) controller.presentInGlobalOverlay(standardTextAlertController(theme: AlertControllerTheme(presentationData: self.presentationData), title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: {})]))
@ -430,7 +431,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
case .codeExpired: case .codeExpired:
text = strongSelf.presentationData.strings.Login_CodeExpired text = strongSelf.presentationData.strings.Login_CodeExpired
let account = strongSelf.account let account = strongSelf.account
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone()
case .timeout: case .timeout:
text = strongSelf.presentationData.strings.Login_NetworkError text = strongSelf.presentationData.strings.Login_NetworkError
case .invalidEmailToken: case .invalidEmailToken:
@ -490,7 +491,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
return return
} }
let account = strongSelf.account let account = strongSelf.account
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone()
})]), on: .root, blockInteraction: false, completion: {}) })]), on: .root, blockInteraction: false, completion: {})
}) })
], actionLayout: .vertical, dismissOnOutsideTap: true) ], actionLayout: .vertical, dismissOnOutsideTap: true)
@ -522,7 +523,14 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
controller.inProgress = false controller.inProgress = false
if case .invalidCode = error { if case .invalidCode = error {
controller.animateError(text: strongSelf.presentationData.strings.Login_WrongCodeError) let text: String
switch type {
case .word, .phrase:
text = strongSelf.presentationData.strings.Login_WrongPhraseError
default:
text = strongSelf.presentationData.strings.Login_WrongCodeError
}
controller.animateError(text: text)
} else { } else {
var resetCode = false var resetCode = false
let text: String let text: String
@ -538,7 +546,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
case .codeExpired: case .codeExpired:
text = strongSelf.presentationData.strings.Login_CodeExpired text = strongSelf.presentationData.strings.Login_CodeExpired
let account = strongSelf.account let account = strongSelf.account
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone()
case .invalidEmailToken: case .invalidEmailToken:
text = strongSelf.presentationData.strings.Login_InvalidEmailTokenError text = strongSelf.presentationData.strings.Login_InvalidEmailTokenError
case .invalidEmailAddress: case .invalidEmailAddress:
@ -562,7 +570,11 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
if let strongSelf = self { if let strongSelf = self {
if nextType == nil { if nextType == nil {
if let controller { if let controller {
AuthorizationSequenceController.presentDidNotGetCodeUI(controller: controller, presentationData: strongSelf.presentationData, number: number) let carrier = CTCarrier()
let mnc = carrier.mobileNetworkCode ?? "none"
let _ = strongSelf.engine.auth.reportMissingCode(phoneNumber: number, phoneCodeHash: phoneCodeHash, mnc: mnc).start()
AuthorizationSequenceController.presentDidNotGetCodeUI(controller: controller, presentationData: strongSelf.presentationData, phoneNumber: number, mnc: mnc)
} }
} else { } else {
controller?.inProgress = true controller?.inProgress = true
@ -607,7 +619,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
controller.reset = { [weak self] in controller.reset = { [weak self] in
if let strongSelf = self { if let strongSelf = self {
let account = strongSelf.account let account = strongSelf.account
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone()
} }
} }
controller.signInWithApple = { [weak self] in controller.signInWithApple = { [weak self] in
@ -659,7 +671,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
} }
let countryCode = AuthorizationSequenceController.defaultCountryCode() let countryCode = AuthorizationSequenceController.defaultCountryCode()
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone()
}) })
} }
controller.proceedWithEmail = { [weak self, weak controller] email in controller.proceedWithEmail = { [weak self, weak controller] email in
@ -783,7 +795,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
case .codeExpired: case .codeExpired:
text = strongSelf.presentationData.strings.Login_CodeExpired text = strongSelf.presentationData.strings.Login_CodeExpired
let account = strongSelf.account let account = strongSelf.account
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone()
case .invalidEmailToken: case .invalidEmailToken:
text = strongSelf.presentationData.strings.Login_InvalidEmailTokenError text = strongSelf.presentationData.strings.Login_InvalidEmailTokenError
case .invalidEmailAddress: case .invalidEmailAddress:
@ -832,7 +844,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
} }
let countryCode = AuthorizationSequenceController.defaultCountryCode() let countryCode = AuthorizationSequenceController.defaultCountryCode()
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone()
}) })
controller.loginWithPassword = { [weak self, weak controller] password in controller.loginWithPassword = { [weak self, weak controller] password in
if let strongSelf = self { if let strongSelf = self {
@ -864,19 +876,19 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
controller.forgot = { [weak self, weak controller] in controller.forgot = { [weak self, weak controller] in
if let strongSelf = self, let strongController = controller { if let strongSelf = self, let strongController = controller {
strongController.inProgress = true strongController.inProgress = true
strongSelf.actionDisposable.set((TelegramEngineUnauthorized(account: strongSelf.account).auth.requestTwoStepVerificationPasswordRecoveryCode() strongSelf.actionDisposable.set((strongSelf.engine.auth.requestTwoStepVerificationPasswordRecoveryCode()
|> deliverOnMainQueue).startStrict(next: { pattern in |> deliverOnMainQueue).startStrict(next: { pattern in
if let strongSelf = self, let strongController = controller { if let strongSelf = self, let strongController = controller {
strongController.inProgress = false strongController.inProgress = false
let _ = (TelegramEngineUnauthorized(account: strongSelf.account).auth.state() let _ = (strongSelf.engine.auth.state()
|> take(1) |> take(1)
|> deliverOnMainQueue).startStandalone(next: { state in |> deliverOnMainQueue).startStandalone(next: { state in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
if case let .unauthorized(state) = state, case let .passwordEntry(hint, number, code, _, syncContacts) = state.contents { if case let .unauthorized(state) = state, case let .passwordEntry(hint, number, code, _, syncContacts) = state.contents {
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .passwordRecovery(hint: hint, number: number, code: code, emailPattern: pattern, syncContacts: syncContacts))).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .passwordRecovery(hint: hint, number: number, code: code, emailPattern: pattern, syncContacts: syncContacts))).startStandalone()
} }
}) })
} }
@ -937,7 +949,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
if let currentController = currentController { if let currentController = currentController {
controller = currentController controller = currentController
} else { } else {
controller = TwoFactorDataInputScreen(sharedContext: self.sharedContext, engine: .unauthorized(TelegramEngineUnauthorized(account: self.account)), mode: .passwordRecoveryEmail(emailPattern: emailPattern, mode: .notAuthorized(syncContacts: syncContacts), doneText: self.presentationData.strings.TwoFactorSetup_Done_Action), stateUpdated: { _ in controller = TwoFactorDataInputScreen(sharedContext: self.sharedContext, engine: .unauthorized(self.engine), mode: .passwordRecoveryEmail(emailPattern: emailPattern, mode: .notAuthorized(syncContacts: syncContacts), doneText: self.presentationData.strings.TwoFactorSetup_Done_Action), stateUpdated: { _ in
}, presentation: .default) }, presentation: .default)
} }
controller.passwordRecoveryFailed = { [weak self] in controller.passwordRecoveryFailed = { [weak self] in
@ -945,14 +957,14 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
return return
} }
let _ = (TelegramEngineUnauthorized(account: strongSelf.account).auth.state() let _ = (strongSelf.engine.auth.state()
|> take(1) |> take(1)
|> deliverOnMainQueue).startStandalone(next: { state in |> deliverOnMainQueue).startStandalone(next: { state in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
if case let .unauthorized(state) = state, case let .passwordRecovery(hint, number, code, _, syncContacts) = state.contents { if case let .unauthorized(state) = state, case let .passwordRecovery(hint, number, code, _, syncContacts) = state.contents {
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .passwordEntry(hint: hint, number: number, code: code, suggestReset: true, syncContacts: syncContacts))).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .passwordEntry(hint: hint, number: number, code: code, suggestReset: true, syncContacts: syncContacts))).startStandalone()
} }
}) })
} }
@ -977,7 +989,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
} }
let countryCode = AuthorizationSequenceController.defaultCountryCode() let countryCode = AuthorizationSequenceController.defaultCountryCode()
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone()
}) })
controller.reset = { [weak self, weak controller] in controller.reset = { [weak self, weak controller] in
if let strongSelf = self, let strongController = controller { if let strongSelf = self, let strongController = controller {
@ -1011,7 +1023,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
controller.logout = { [weak self] in controller.logout = { [weak self] in
if let strongSelf = self { if let strongSelf = self {
let account = strongSelf.account let account = strongSelf.account
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .empty)).startStandalone()
} }
} }
} }
@ -1037,7 +1049,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
} }
let countryCode = AuthorizationSequenceController.defaultCountryCode() let countryCode = AuthorizationSequenceController.defaultCountryCode()
let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone() let _ = strongSelf.engine.auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).startStandalone()
}, displayCancel: displayCancel) }, displayCancel: displayCancel)
controller.openUrl = { [weak self] url in controller.openUrl = { [weak self] url in
guard let self else { guard let self else {
@ -1056,7 +1068,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
let avatarVideo: Signal<UploadedPeerPhotoData?, NoError>? let avatarVideo: Signal<UploadedPeerPhotoData?, NoError>?
if let avatarAsset = avatarAsset as? AVAsset { if let avatarAsset = avatarAsset as? AVAsset {
let account = strongSelf.account let engine = strongSelf.engine
avatarVideo = Signal<TelegramMediaResource?, NoError> { subscriber in avatarVideo = Signal<TelegramMediaResource?, NoError> { subscriber in
let entityRenderer: LegacyPaintEntityRenderer? = avatarAdjustments.flatMap { adjustments in let entityRenderer: LegacyPaintEntityRenderer? = avatarAdjustments.flatMap { adjustments in
if let paintingData = adjustments.paintingData, paintingData.hasAnimation { if let paintingData = adjustments.paintingData, paintingData.hasAnimation {
@ -1075,7 +1087,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
if stat(result.fileURL.path, &value) == 0 { if stat(result.fileURL.path, &value) == 0 {
if let data = try? Data(contentsOf: result.fileURL) { if let data = try? Data(contentsOf: result.fileURL) {
let resource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max)) let resource = LocalFileMediaResource(fileId: Int64.random(in: Int64.min ... Int64.max))
account.postbox.mediaBox.storeResourceData(resource.id, data: data, synchronous: true) engine.account.postbox.mediaBox.storeResourceData(resource.id, data: data, synchronous: true)
subscriber.putNext(resource) subscriber.putNext(resource)
EngineTempBox.shared.dispose(tempFile) EngineTempBox.shared.dispose(tempFile)
@ -1096,7 +1108,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
} }
|> mapToSignal { resource -> Signal<UploadedPeerPhotoData?, NoError> in |> mapToSignal { resource -> Signal<UploadedPeerPhotoData?, NoError> in
if let resource = resource { if let resource = resource {
return TelegramEngineUnauthorized(account: account).auth.uploadedPeerVideo(resource: resource) |> map(Optional.init) return engine.auth.uploadedPeerVideo(resource: resource) |> map(Optional.init)
} else { } else {
return .single(nil) return .single(nil)
} }
@ -1320,9 +1332,14 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
return countryCode return countryCode
} }
public static func presentDidNotGetCodeUI(controller: ViewController, presentationData: PresentationData, number: String) { public static func presentDidNotGetCodeUI(
controller: ViewController,
presentationData: PresentationData,
phoneNumber: String,
mnc: String
) {
if MFMailComposeViewController.canSendMail() { if MFMailComposeViewController.canSendMail() {
let formattedNumber = formatPhoneNumber(number) let formattedNumber = formatPhoneNumber(phoneNumber)
var emailBody = "" var emailBody = ""
emailBody.append(presentationData.strings.Login_EmailCodeBody(formattedNumber).string) emailBody.append(presentationData.strings.Login_EmailCodeBody(formattedNumber).string)
@ -1331,8 +1348,6 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
let appVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? "unknown" let appVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? "unknown"
let systemVersion = UIDevice.current.systemVersion let systemVersion = UIDevice.current.systemVersion
let locale = Locale.current.identifier let locale = Locale.current.identifier
let carrier = CTCarrier()
let mnc = carrier.mobileNetworkCode ?? "none"
emailBody.append("Telegram: \(appVersion)\n") emailBody.append("Telegram: \(appVersion)\n")
emailBody.append("OS: \(systemVersion)\n") emailBody.append("OS: \(systemVersion)\n")
emailBody.append("Locale: \(locale)\n") emailBody.append("Locale: \(locale)\n")

View File

@ -41,39 +41,53 @@ public func authorizationCurrentOptionText(_ type: SentAuthorizationCodeType, ph
return parseMarkdownIntoAttributedString(strings.Login_EnterCodeFragmentText(phoneNumber).string, attributes: attributes, textAlignment: .center) return parseMarkdownIntoAttributedString(strings.Login_EnterCodeFragmentText(phoneNumber).string, attributes: attributes, textAlignment: .center)
case .firebase: case .firebase:
return parseMarkdownIntoAttributedString(strings.Login_EnterCodeSMSText(phoneNumber).string, attributes: attributes, textAlignment: .center) return parseMarkdownIntoAttributedString(strings.Login_EnterCodeSMSText(phoneNumber).string, attributes: attributes, textAlignment: .center)
case let .word(startsWith):
if let startsWith {
return parseMarkdownIntoAttributedString(strings.Login_EnterWordBeginningText(startsWith, phoneNumber).string, attributes: attributes, textAlignment: .center)
} else {
return parseMarkdownIntoAttributedString(strings.Login_EnterWordText(phoneNumber).string, attributes: attributes, textAlignment: .center)
}
case let .phrase(startsWith):
if let startsWith {
return parseMarkdownIntoAttributedString(strings.Login_EnterPhraseBeginningText(startsWith, phoneNumber).string, attributes: attributes, textAlignment: .center)
} else {
return parseMarkdownIntoAttributedString(strings.Login_EnterPhraseText(phoneNumber).string, attributes: attributes, textAlignment: .center)
}
} }
} }
public func authorizationNextOptionText(currentType: SentAuthorizationCodeType, nextType: AuthorizationCodeNextType?, timeout: Int32?, strings: PresentationStrings, primaryColor: UIColor, accentColor: UIColor) -> (NSAttributedString, Bool) { public func authorizationNextOptionText(currentType: SentAuthorizationCodeType, nextType: AuthorizationCodeNextType?, timeout: Int32?, strings: PresentationStrings, primaryColor: UIColor, accentColor: UIColor) -> (NSAttributedString, Bool) {
let font = Font.regular(16.0)
if let nextType = nextType, let timeout = timeout, timeout > 0 { if let nextType = nextType, let timeout = timeout, timeout > 0 {
let minutes = timeout / 60 let minutes = timeout / 60
let seconds = timeout % 60 let seconds = timeout % 60
switch nextType { switch nextType {
case .sms: case .sms:
if timeout <= 0 { if timeout <= 0 {
return (NSAttributedString(string: strings.Login_CodeSentSms, font: Font.regular(16.0), textColor: primaryColor, paragraphAlignment: .center), false) return (NSAttributedString(string: strings.Login_CodeSentSms, font: font, textColor: primaryColor, paragraphAlignment: .center), false)
} else { } else {
let timeString = NSString(format: "%d:%.02d", Int(minutes), Int(seconds)) let timeString = NSString(format: "%d:%.02d", Int(minutes), Int(seconds))
return (NSAttributedString(string: strings.Login_WillSendSms(timeString as String).string, font: Font.regular(16.0), textColor: primaryColor, paragraphAlignment: .center), false) return (NSAttributedString(string: strings.Login_WillSendSms(timeString as String).string, font: font, textColor: primaryColor, paragraphAlignment: .center), false)
} }
case .call: case .call:
if timeout <= 0 { if timeout <= 0 {
return (NSAttributedString(string: strings.Login_CodeSentCall, font: Font.regular(16.0), textColor: primaryColor, paragraphAlignment: .center), false) return (NSAttributedString(string: strings.Login_CodeSentCall, font: font, textColor: primaryColor, paragraphAlignment: .center), false)
} else { } else {
return (NSAttributedString(string: String(format: strings.ChangePhoneNumberCode_CallTimer(String(format: "%d:%.2d", minutes, seconds)).string, minutes, seconds), font: Font.regular(16.0), textColor: primaryColor, paragraphAlignment: .center), false) return (NSAttributedString(string: String(format: strings.ChangePhoneNumberCode_CallTimer(String(format: "%d:%.2d", minutes, seconds)).string, minutes, seconds), font: font, textColor: primaryColor, paragraphAlignment: .center), false)
} }
case .flashCall, .missedCall: case .flashCall, .missedCall:
if timeout <= 0 { if timeout <= 0 {
return (NSAttributedString(string: strings.ChangePhoneNumberCode_Called, font: Font.regular(16.0), textColor: primaryColor, paragraphAlignment: .center), false) return (NSAttributedString(string: strings.ChangePhoneNumberCode_Called, font: font, textColor: primaryColor, paragraphAlignment: .center), false)
} else { } else {
return (NSAttributedString(string: String(format: strings.ChangePhoneNumberCode_CallTimer(String(format: "%d:%.2d", minutes, seconds)).string, minutes, seconds), font: Font.regular(16.0), textColor: primaryColor, paragraphAlignment: .center), false) return (NSAttributedString(string: String(format: strings.ChangePhoneNumberCode_CallTimer(String(format: "%d:%.2d", minutes, seconds)).string, minutes, seconds), font: font, textColor: primaryColor, paragraphAlignment: .center), false)
} }
case .fragment: case .fragment:
if timeout <= 0 { if timeout <= 0 {
return (NSAttributedString(string: strings.Login_CodeSentSms, font: Font.regular(16.0), textColor: primaryColor, paragraphAlignment: .center), false) return (NSAttributedString(string: strings.Login_CodeSentSms, font: font, textColor: primaryColor, paragraphAlignment: .center), false)
} else { } else {
let timeString = NSString(format: "%d:%.02d", Int(minutes), Int(seconds)) let timeString = NSString(format: "%d:%.02d", Int(minutes), Int(seconds))
return (NSAttributedString(string: strings.Login_WillSendSms(timeString as String).string, font: Font.regular(16.0), textColor: primaryColor, paragraphAlignment: .center), false) return (NSAttributedString(string: strings.Login_WillSendSms(timeString as String).string, font: font, textColor: primaryColor, paragraphAlignment: .center), false)
} }
} }
} else { } else {
@ -81,28 +95,28 @@ public func authorizationNextOptionText(currentType: SentAuthorizationCodeType,
case .otherSession: case .otherSession:
switch nextType { switch nextType {
case .sms: case .sms:
return (NSAttributedString(string: strings.Login_SendCodeViaSms, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_SendCodeViaSms, font: font, textColor: accentColor, paragraphAlignment: .center), true)
case .call: case .call:
return (NSAttributedString(string: strings.Login_SendCodeViaCall, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_SendCodeViaCall, font: font, textColor: accentColor, paragraphAlignment: .center), true)
case .flashCall, .missedCall: case .flashCall, .missedCall:
return (NSAttributedString(string: strings.Login_SendCodeViaFlashCall, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_SendCodeViaFlashCall, font: font, textColor: accentColor, paragraphAlignment: .center), true)
case .fragment: case .fragment:
return (NSAttributedString(string: strings.Login_GetCodeViaFragment, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_GetCodeViaFragment, font: font, textColor: accentColor, paragraphAlignment: .center), true)
case .none: case .none:
return (NSAttributedString(string: strings.Login_HaveNotReceivedCodeInternal, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_HaveNotReceivedCodeInternal, font: font, textColor: accentColor, paragraphAlignment: .center), true)
} }
default: default:
switch nextType { switch nextType {
case .sms: case .sms:
return (NSAttributedString(string: strings.Login_SendCodeViaSms, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_SendCodeViaSms, font: font, textColor: accentColor, paragraphAlignment: .center), true)
case .call: case .call:
return (NSAttributedString(string: strings.Login_SendCodeViaCall, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_SendCodeViaCall, font: font, textColor: accentColor, paragraphAlignment: .center), true)
case .flashCall, .missedCall: case .flashCall, .missedCall:
return (NSAttributedString(string: strings.Login_SendCodeViaFlashCall, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_SendCodeViaFlashCall, font: font, textColor: accentColor, paragraphAlignment: .center), true)
case .fragment: case .fragment:
return (NSAttributedString(string: strings.Login_GetCodeViaFragment, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_GetCodeViaFragment, font: font, textColor: accentColor, paragraphAlignment: .center), true)
case .none: case .none:
return (NSAttributedString(string: strings.Login_HaveNotReceivedCodeInternal, font: Font.regular(16.0), textColor: accentColor, paragraphAlignment: .center), true) return (NSAttributedString(string: strings.Login_HaveNotReceivedCodeInternal, font: font, textColor: accentColor, paragraphAlignment: .center), true)
} }
} }
} }

View File

@ -99,7 +99,11 @@ public func ChangePhoneNumberController(context: AccountContext) -> ViewControll
guard let codeController else { guard let codeController else {
return return
} }
AuthorizationSequenceController.presentDidNotGetCodeUI(controller: codeController, presentationData: context.sharedContext.currentPresentationData.with({ $0 }), number: phoneNumber) let carrier = CTCarrier()
let mnc = carrier.mobileNetworkCode ?? "none"
let _ = context.engine.auth.reportMissingCode(phoneNumber: phoneNumber, phoneCodeHash: next.hash, mnc: mnc).start()
AuthorizationSequenceController.presentDidNotGetCodeUI(controller: codeController, presentationData: context.sharedContext.currentPresentationData.with({ $0 }), phoneNumber: phoneNumber, mnc: mnc)
} }
codeController.openFragment = { url in codeController.openFragment = { url in
context.sharedContext.applicationBindings.openUrl(url) context.sharedContext.applicationBindings.openUrl(url)

View File

@ -1135,6 +1135,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-2113903484] = { return Api.auth.SentCodeType.parse_sentCodeTypeMissedCall($0) } dict[-2113903484] = { return Api.auth.SentCodeType.parse_sentCodeTypeMissedCall($0) }
dict[-1521934870] = { return Api.auth.SentCodeType.parse_sentCodeTypeSetUpEmailRequired($0) } dict[-1521934870] = { return Api.auth.SentCodeType.parse_sentCodeTypeSetUpEmailRequired($0) }
dict[-1073693790] = { return Api.auth.SentCodeType.parse_sentCodeTypeSms($0) } dict[-1073693790] = { return Api.auth.SentCodeType.parse_sentCodeTypeSms($0) }
dict[-1284008785] = { return Api.auth.SentCodeType.parse_sentCodeTypeSmsPhrase($0) }
dict[-1542017919] = { return Api.auth.SentCodeType.parse_sentCodeTypeSmsWord($0) }
dict[-391678544] = { return Api.bots.BotInfo.parse_botInfo($0) } dict[-391678544] = { return Api.bots.BotInfo.parse_botInfo($0) }
dict[-309659827] = { return Api.channels.AdminLogResults.parse_adminLogResults($0) } dict[-309659827] = { return Api.channels.AdminLogResults.parse_adminLogResults($0) }
dict[-541588713] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) } dict[-541588713] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) }
@ -1356,7 +1358,7 @@ public extension Api {
return parser(reader) return parser(reader)
} }
else { else {
telegramApiLog("Type constructor \(String(UInt32(bitPattern: signature), radix: 16, uppercase: false)) not found") telegramApiLog("Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
return nil return nil
} }
} }

View File

@ -595,6 +595,8 @@ public extension Api.auth {
case sentCodeTypeMissedCall(prefix: String, length: Int32) case sentCodeTypeMissedCall(prefix: String, length: Int32)
case sentCodeTypeSetUpEmailRequired(flags: Int32) case sentCodeTypeSetUpEmailRequired(flags: Int32)
case sentCodeTypeSms(length: Int32) case sentCodeTypeSms(length: Int32)
case sentCodeTypeSmsPhrase(flags: Int32, beginning: String?)
case sentCodeTypeSmsWord(flags: Int32, beginning: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
@ -662,6 +664,20 @@ public extension Api.auth {
} }
serializeInt32(length, buffer: buffer, boxed: false) serializeInt32(length, buffer: buffer, boxed: false)
break break
case .sentCodeTypeSmsPhrase(let flags, let beginning):
if boxed {
buffer.appendInt32(-1284008785)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(beginning!, buffer: buffer, boxed: false)}
break
case .sentCodeTypeSmsWord(let flags, let beginning):
if boxed {
buffer.appendInt32(-1542017919)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(beginning!, buffer: buffer, boxed: false)}
break
} }
} }
@ -685,6 +701,10 @@ public extension Api.auth {
return ("sentCodeTypeSetUpEmailRequired", [("flags", flags as Any)]) return ("sentCodeTypeSetUpEmailRequired", [("flags", flags as Any)])
case .sentCodeTypeSms(let length): case .sentCodeTypeSms(let length):
return ("sentCodeTypeSms", [("length", length as Any)]) return ("sentCodeTypeSms", [("length", length as Any)])
case .sentCodeTypeSmsPhrase(let flags, let beginning):
return ("sentCodeTypeSmsPhrase", [("flags", flags as Any), ("beginning", beginning as Any)])
case .sentCodeTypeSmsWord(let flags, let beginning):
return ("sentCodeTypeSmsWord", [("flags", flags as Any), ("beginning", beginning as Any)])
} }
} }
@ -817,6 +837,34 @@ public extension Api.auth {
return nil return nil
} }
} }
public static func parse_sentCodeTypeSmsPhrase(_ reader: BufferReader) -> SentCodeType? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
if Int(_1!) & Int(1 << 0) != 0 {_2 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
if _c1 && _c2 {
return Api.auth.SentCodeType.sentCodeTypeSmsPhrase(flags: _1!, beginning: _2)
}
else {
return nil
}
}
public static func parse_sentCodeTypeSmsWord(_ reader: BufferReader) -> SentCodeType? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
if Int(_1!) & Int(1 << 0) != 0 {_2 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
if _c1 && _c2 {
return Api.auth.SentCodeType.sentCodeTypeSmsWord(flags: _1!, beginning: _2)
}
else {
return nil
}
}
} }
} }
@ -926,139 +974,3 @@ public extension Api.channels {
} }
} }
public extension Api.channels {
enum ChannelParticipant: TypeConstructorDescription {
case channelParticipant(participant: Api.ChannelParticipant, chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .channelParticipant(let participant, let chats, let users):
if boxed {
buffer.appendInt32(-541588713)
}
participant.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .channelParticipant(let participant, let chats, let users):
return ("channelParticipant", [("participant", participant as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_channelParticipant(_ reader: BufferReader) -> ChannelParticipant? {
var _1: Api.ChannelParticipant?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.ChannelParticipant
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.channels.ChannelParticipant.channelParticipant(participant: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.channels {
enum ChannelParticipants: TypeConstructorDescription {
case channelParticipants(count: Int32, participants: [Api.ChannelParticipant], chats: [Api.Chat], users: [Api.User])
case channelParticipantsNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .channelParticipants(let count, let participants, let chats, let users):
if boxed {
buffer.appendInt32(-1699676497)
}
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(participants.count))
for item in participants {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
case .channelParticipantsNotModified:
if boxed {
buffer.appendInt32(-266911767)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .channelParticipants(let count, let participants, let chats, let users):
return ("channelParticipants", [("count", count as Any), ("participants", participants as Any), ("chats", chats as Any), ("users", users as Any)])
case .channelParticipantsNotModified:
return ("channelParticipantsNotModified", [])
}
}
public static func parse_channelParticipants(_ reader: BufferReader) -> ChannelParticipants? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.ChannelParticipant]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ChannelParticipant.self)
}
var _3: [Api.Chat]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _4: [Api.User]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.channels.ChannelParticipants.channelParticipants(count: _1!, participants: _2!, chats: _3!, users: _4!)
}
else {
return nil
}
}
public static func parse_channelParticipantsNotModified(_ reader: BufferReader) -> ChannelParticipants? {
return Api.channels.ChannelParticipants.channelParticipantsNotModified
}
}
}

View File

@ -1,3 +1,139 @@
public extension Api.channels {
enum ChannelParticipant: TypeConstructorDescription {
case channelParticipant(participant: Api.ChannelParticipant, chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .channelParticipant(let participant, let chats, let users):
if boxed {
buffer.appendInt32(-541588713)
}
participant.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .channelParticipant(let participant, let chats, let users):
return ("channelParticipant", [("participant", participant as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_channelParticipant(_ reader: BufferReader) -> ChannelParticipant? {
var _1: Api.ChannelParticipant?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.ChannelParticipant
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.channels.ChannelParticipant.channelParticipant(participant: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.channels {
enum ChannelParticipants: TypeConstructorDescription {
case channelParticipants(count: Int32, participants: [Api.ChannelParticipant], chats: [Api.Chat], users: [Api.User])
case channelParticipantsNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .channelParticipants(let count, let participants, let chats, let users):
if boxed {
buffer.appendInt32(-1699676497)
}
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(participants.count))
for item in participants {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
case .channelParticipantsNotModified:
if boxed {
buffer.appendInt32(-266911767)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .channelParticipants(let count, let participants, let chats, let users):
return ("channelParticipants", [("count", count as Any), ("participants", participants as Any), ("chats", chats as Any), ("users", users as Any)])
case .channelParticipantsNotModified:
return ("channelParticipantsNotModified", [])
}
}
public static func parse_channelParticipants(_ reader: BufferReader) -> ChannelParticipants? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.ChannelParticipant]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ChannelParticipant.self)
}
var _3: [Api.Chat]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _4: [Api.User]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.channels.ChannelParticipants.channelParticipants(count: _1!, participants: _2!, chats: _3!, users: _4!)
}
else {
return nil
}
}
public static func parse_channelParticipantsNotModified(_ reader: BufferReader) -> ChannelParticipants? {
return Api.channels.ChannelParticipants.channelParticipantsNotModified
}
}
}
public extension Api.channels { public extension Api.channels {
enum SendAsPeers: TypeConstructorDescription { enum SendAsPeers: TypeConstructorDescription {
case sendAsPeers(peers: [Api.SendAsPeer], chats: [Api.Chat], users: [Api.User]) case sendAsPeers(peers: [Api.SendAsPeer], chats: [Api.Chat], users: [Api.User])
@ -1324,101 +1460,3 @@ public extension Api.help {
} }
} }
public extension Api.help {
enum DeepLinkInfo: TypeConstructorDescription {
case deepLinkInfo(flags: Int32, message: String, entities: [Api.MessageEntity]?)
case deepLinkInfoEmpty
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .deepLinkInfo(let flags, let message, let entities):
if boxed {
buffer.appendInt32(1783556146)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(message, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(entities!.count))
for item in entities! {
item.serialize(buffer, true)
}}
break
case .deepLinkInfoEmpty:
if boxed {
buffer.appendInt32(1722786150)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .deepLinkInfo(let flags, let message, let entities):
return ("deepLinkInfo", [("flags", flags as Any), ("message", message as Any), ("entities", entities as Any)])
case .deepLinkInfoEmpty:
return ("deepLinkInfoEmpty", [])
}
}
public static func parse_deepLinkInfo(_ reader: BufferReader) -> DeepLinkInfo? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
if _c1 && _c2 && _c3 {
return Api.help.DeepLinkInfo.deepLinkInfo(flags: _1!, message: _2!, entities: _3)
}
else {
return nil
}
}
public static func parse_deepLinkInfoEmpty(_ reader: BufferReader) -> DeepLinkInfo? {
return Api.help.DeepLinkInfo.deepLinkInfoEmpty
}
}
}
public extension Api.help {
enum InviteText: TypeConstructorDescription {
case inviteText(message: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .inviteText(let message):
if boxed {
buffer.appendInt32(415997816)
}
serializeString(message, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .inviteText(let message):
return ("inviteText", [("message", message as Any)])
}
}
public static func parse_inviteText(_ reader: BufferReader) -> InviteText? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.help.InviteText.inviteText(message: _1!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,101 @@
public extension Api.help {
enum DeepLinkInfo: TypeConstructorDescription {
case deepLinkInfo(flags: Int32, message: String, entities: [Api.MessageEntity]?)
case deepLinkInfoEmpty
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .deepLinkInfo(let flags, let message, let entities):
if boxed {
buffer.appendInt32(1783556146)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(message, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(entities!.count))
for item in entities! {
item.serialize(buffer, true)
}}
break
case .deepLinkInfoEmpty:
if boxed {
buffer.appendInt32(1722786150)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .deepLinkInfo(let flags, let message, let entities):
return ("deepLinkInfo", [("flags", flags as Any), ("message", message as Any), ("entities", entities as Any)])
case .deepLinkInfoEmpty:
return ("deepLinkInfoEmpty", [])
}
}
public static func parse_deepLinkInfo(_ reader: BufferReader) -> DeepLinkInfo? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
if _c1 && _c2 && _c3 {
return Api.help.DeepLinkInfo.deepLinkInfo(flags: _1!, message: _2!, entities: _3)
}
else {
return nil
}
}
public static func parse_deepLinkInfoEmpty(_ reader: BufferReader) -> DeepLinkInfo? {
return Api.help.DeepLinkInfo.deepLinkInfoEmpty
}
}
}
public extension Api.help {
enum InviteText: TypeConstructorDescription {
case inviteText(message: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .inviteText(let message):
if boxed {
buffer.appendInt32(415997816)
}
serializeString(message, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .inviteText(let message):
return ("inviteText", [("message", message as Any)])
}
}
public static func parse_inviteText(_ reader: BufferReader) -> InviteText? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.help.InviteText.inviteText(message: _1!)
}
else {
return nil
}
}
}
}
public extension Api.help { public extension Api.help {
enum PassportConfig: TypeConstructorDescription { enum PassportConfig: TypeConstructorDescription {
case passportConfig(hash: Int32, countriesLangs: Api.DataJSON) case passportConfig(hash: Int32, countriesLangs: Api.DataJSON)
@ -1166,183 +1264,3 @@ public extension Api.messages {
} }
} }
public extension Api.messages {
enum BotCallbackAnswer: TypeConstructorDescription {
case botCallbackAnswer(flags: Int32, message: String?, url: String?, cacheTime: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .botCallbackAnswer(let flags, let message, let url, let cacheTime):
if boxed {
buffer.appendInt32(911761060)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(message!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeString(url!, buffer: buffer, boxed: false)}
serializeInt32(cacheTime, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .botCallbackAnswer(let flags, let message, let url, let cacheTime):
return ("botCallbackAnswer", [("flags", flags as Any), ("message", message as Any), ("url", url as Any), ("cacheTime", cacheTime as Any)])
}
}
public static func parse_botCallbackAnswer(_ reader: BufferReader) -> BotCallbackAnswer? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
if Int(_1!) & Int(1 << 0) != 0 {_2 = parseString(reader) }
var _3: String?
if Int(_1!) & Int(1 << 2) != 0 {_3 = parseString(reader) }
var _4: Int32?
_4 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 2) == 0) || _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.messages.BotCallbackAnswer.botCallbackAnswer(flags: _1!, message: _2, url: _3, cacheTime: _4!)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum BotResults: TypeConstructorDescription {
case botResults(flags: Int32, queryId: Int64, nextOffset: String?, switchPm: Api.InlineBotSwitchPM?, switchWebview: Api.InlineBotWebView?, results: [Api.BotInlineResult], cacheTime: Int32, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .botResults(let flags, let queryId, let nextOffset, let switchPm, let switchWebview, let results, let cacheTime, let users):
if boxed {
buffer.appendInt32(-534646026)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(queryId, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {switchPm!.serialize(buffer, true)}
if Int(flags) & Int(1 << 3) != 0 {switchWebview!.serialize(buffer, true)}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(results.count))
for item in results {
item.serialize(buffer, true)
}
serializeInt32(cacheTime, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .botResults(let flags, let queryId, let nextOffset, let switchPm, let switchWebview, let results, let cacheTime, let users):
return ("botResults", [("flags", flags as Any), ("queryId", queryId as Any), ("nextOffset", nextOffset as Any), ("switchPm", switchPm as Any), ("switchWebview", switchWebview as Any), ("results", results as Any), ("cacheTime", cacheTime as Any), ("users", users as Any)])
}
}
public static func parse_botResults(_ reader: BufferReader) -> BotResults? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
var _3: String?
if Int(_1!) & Int(1 << 1) != 0 {_3 = parseString(reader) }
var _4: Api.InlineBotSwitchPM?
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.InlineBotSwitchPM
} }
var _5: Api.InlineBotWebView?
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.InlineBotWebView
} }
var _6: [Api.BotInlineResult]?
if let _ = reader.readInt32() {
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.BotInlineResult.self)
}
var _7: Int32?
_7 = reader.readInt32()
var _8: [Api.User]?
if let _ = reader.readInt32() {
_8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.messages.BotResults.botResults(flags: _1!, queryId: _2!, nextOffset: _3, switchPm: _4, switchWebview: _5, results: _6!, cacheTime: _7!, users: _8!)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum ChatAdminsWithInvites: TypeConstructorDescription {
case chatAdminsWithInvites(admins: [Api.ChatAdminWithInvites], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .chatAdminsWithInvites(let admins, let users):
if boxed {
buffer.appendInt32(-1231326505)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(admins.count))
for item in admins {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .chatAdminsWithInvites(let admins, let users):
return ("chatAdminsWithInvites", [("admins", admins as Any), ("users", users as Any)])
}
}
public static func parse_chatAdminsWithInvites(_ reader: BufferReader) -> ChatAdminsWithInvites? {
var _1: [Api.ChatAdminWithInvites]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ChatAdminWithInvites.self)
}
var _2: [Api.User]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.messages.ChatAdminsWithInvites.chatAdminsWithInvites(admins: _1!, users: _2!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,183 @@
public extension Api.messages {
enum BotCallbackAnswer: TypeConstructorDescription {
case botCallbackAnswer(flags: Int32, message: String?, url: String?, cacheTime: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .botCallbackAnswer(let flags, let message, let url, let cacheTime):
if boxed {
buffer.appendInt32(911761060)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(message!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeString(url!, buffer: buffer, boxed: false)}
serializeInt32(cacheTime, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .botCallbackAnswer(let flags, let message, let url, let cacheTime):
return ("botCallbackAnswer", [("flags", flags as Any), ("message", message as Any), ("url", url as Any), ("cacheTime", cacheTime as Any)])
}
}
public static func parse_botCallbackAnswer(_ reader: BufferReader) -> BotCallbackAnswer? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
if Int(_1!) & Int(1 << 0) != 0 {_2 = parseString(reader) }
var _3: String?
if Int(_1!) & Int(1 << 2) != 0 {_3 = parseString(reader) }
var _4: Int32?
_4 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 2) == 0) || _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.messages.BotCallbackAnswer.botCallbackAnswer(flags: _1!, message: _2, url: _3, cacheTime: _4!)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum BotResults: TypeConstructorDescription {
case botResults(flags: Int32, queryId: Int64, nextOffset: String?, switchPm: Api.InlineBotSwitchPM?, switchWebview: Api.InlineBotWebView?, results: [Api.BotInlineResult], cacheTime: Int32, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .botResults(let flags, let queryId, let nextOffset, let switchPm, let switchWebview, let results, let cacheTime, let users):
if boxed {
buffer.appendInt32(-534646026)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(queryId, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {switchPm!.serialize(buffer, true)}
if Int(flags) & Int(1 << 3) != 0 {switchWebview!.serialize(buffer, true)}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(results.count))
for item in results {
item.serialize(buffer, true)
}
serializeInt32(cacheTime, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .botResults(let flags, let queryId, let nextOffset, let switchPm, let switchWebview, let results, let cacheTime, let users):
return ("botResults", [("flags", flags as Any), ("queryId", queryId as Any), ("nextOffset", nextOffset as Any), ("switchPm", switchPm as Any), ("switchWebview", switchWebview as Any), ("results", results as Any), ("cacheTime", cacheTime as Any), ("users", users as Any)])
}
}
public static func parse_botResults(_ reader: BufferReader) -> BotResults? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
var _3: String?
if Int(_1!) & Int(1 << 1) != 0 {_3 = parseString(reader) }
var _4: Api.InlineBotSwitchPM?
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.InlineBotSwitchPM
} }
var _5: Api.InlineBotWebView?
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.InlineBotWebView
} }
var _6: [Api.BotInlineResult]?
if let _ = reader.readInt32() {
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.BotInlineResult.self)
}
var _7: Int32?
_7 = reader.readInt32()
var _8: [Api.User]?
if let _ = reader.readInt32() {
_8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.messages.BotResults.botResults(flags: _1!, queryId: _2!, nextOffset: _3, switchPm: _4, switchWebview: _5, results: _6!, cacheTime: _7!, users: _8!)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum ChatAdminsWithInvites: TypeConstructorDescription {
case chatAdminsWithInvites(admins: [Api.ChatAdminWithInvites], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .chatAdminsWithInvites(let admins, let users):
if boxed {
buffer.appendInt32(-1231326505)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(admins.count))
for item in admins {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .chatAdminsWithInvites(let admins, let users):
return ("chatAdminsWithInvites", [("admins", admins as Any), ("users", users as Any)])
}
}
public static func parse_chatAdminsWithInvites(_ reader: BufferReader) -> ChatAdminsWithInvites? {
var _1: [Api.ChatAdminWithInvites]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ChatAdminWithInvites.self)
}
var _2: [Api.User]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.messages.ChatAdminsWithInvites.chatAdminsWithInvites(admins: _1!, users: _2!)
}
else {
return nil
}
}
}
}
public extension Api.messages { public extension Api.messages {
enum ChatFull: TypeConstructorDescription { enum ChatFull: TypeConstructorDescription {
case chatFull(fullChat: Api.ChatFull, chats: [Api.Chat], users: [Api.User]) case chatFull(fullChat: Api.ChatFull, chats: [Api.Chat], users: [Api.User])
@ -1300,175 +1480,3 @@ public extension Api.messages {
} }
} }
public extension Api.messages {
enum MessageEditData: TypeConstructorDescription {
case messageEditData(flags: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageEditData(let flags):
if boxed {
buffer.appendInt32(649453030)
}
serializeInt32(flags, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageEditData(let flags):
return ("messageEditData", [("flags", flags as Any)])
}
}
public static func parse_messageEditData(_ reader: BufferReader) -> MessageEditData? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.messages.MessageEditData.messageEditData(flags: _1!)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum MessageReactionsList: TypeConstructorDescription {
case messageReactionsList(flags: Int32, count: Int32, reactions: [Api.MessagePeerReaction], chats: [Api.Chat], users: [Api.User], nextOffset: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageReactionsList(let flags, let count, let reactions, let chats, let users, let nextOffset):
if boxed {
buffer.appendInt32(834488621)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(reactions.count))
for item in reactions {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageReactionsList(let flags, let count, let reactions, let chats, let users, let nextOffset):
return ("messageReactionsList", [("flags", flags as Any), ("count", count as Any), ("reactions", reactions as Any), ("chats", chats as Any), ("users", users as Any), ("nextOffset", nextOffset as Any)])
}
}
public static func parse_messageReactionsList(_ reader: BufferReader) -> MessageReactionsList? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: [Api.MessagePeerReaction]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessagePeerReaction.self)
}
var _4: [Api.Chat]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _5: [Api.User]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
var _6: String?
if Int(_1!) & Int(1 << 0) != 0 {_6 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.messages.MessageReactionsList.messageReactionsList(flags: _1!, count: _2!, reactions: _3!, chats: _4!, users: _5!, nextOffset: _6)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum MessageViews: TypeConstructorDescription {
case messageViews(views: [Api.MessageViews], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageViews(let views, let chats, let users):
if boxed {
buffer.appendInt32(-1228606141)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(views.count))
for item in views {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageViews(let views, let chats, let users):
return ("messageViews", [("views", views as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_messageViews(_ reader: BufferReader) -> MessageViews? {
var _1: [Api.MessageViews]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageViews.self)
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.messages.MessageViews.messageViews(views: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,175 @@
public extension Api.messages {
enum MessageEditData: TypeConstructorDescription {
case messageEditData(flags: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageEditData(let flags):
if boxed {
buffer.appendInt32(649453030)
}
serializeInt32(flags, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageEditData(let flags):
return ("messageEditData", [("flags", flags as Any)])
}
}
public static func parse_messageEditData(_ reader: BufferReader) -> MessageEditData? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.messages.MessageEditData.messageEditData(flags: _1!)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum MessageReactionsList: TypeConstructorDescription {
case messageReactionsList(flags: Int32, count: Int32, reactions: [Api.MessagePeerReaction], chats: [Api.Chat], users: [Api.User], nextOffset: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageReactionsList(let flags, let count, let reactions, let chats, let users, let nextOffset):
if boxed {
buffer.appendInt32(834488621)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(reactions.count))
for item in reactions {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageReactionsList(let flags, let count, let reactions, let chats, let users, let nextOffset):
return ("messageReactionsList", [("flags", flags as Any), ("count", count as Any), ("reactions", reactions as Any), ("chats", chats as Any), ("users", users as Any), ("nextOffset", nextOffset as Any)])
}
}
public static func parse_messageReactionsList(_ reader: BufferReader) -> MessageReactionsList? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: [Api.MessagePeerReaction]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessagePeerReaction.self)
}
var _4: [Api.Chat]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _5: [Api.User]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
var _6: String?
if Int(_1!) & Int(1 << 0) != 0 {_6 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.messages.MessageReactionsList.messageReactionsList(flags: _1!, count: _2!, reactions: _3!, chats: _4!, users: _5!, nextOffset: _6)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum MessageViews: TypeConstructorDescription {
case messageViews(views: [Api.MessageViews], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageViews(let views, let chats, let users):
if boxed {
buffer.appendInt32(-1228606141)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(views.count))
for item in views {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageViews(let views, let chats, let users):
return ("messageViews", [("views", views as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_messageViews(_ reader: BufferReader) -> MessageViews? {
var _1: [Api.MessageViews]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageViews.self)
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.messages.MessageViews.messageViews(views: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.messages { public extension Api.messages {
enum Messages: TypeConstructorDescription { enum Messages: TypeConstructorDescription {
case channelMessages(flags: Int32, pts: Int32, count: Int32, offsetIdOffset: Int32?, messages: [Api.Message], topics: [Api.ForumTopic], chats: [Api.Chat], users: [Api.User]) case channelMessages(flags: Int32, pts: Int32, count: Int32, offsetIdOffset: Int32?, messages: [Api.Message], topics: [Api.ForumTopic], chats: [Api.Chat], users: [Api.User])
@ -1292,115 +1464,3 @@ public extension Api.messages {
} }
} }
public extension Api.messages {
enum StickerSetInstallResult: TypeConstructorDescription {
case stickerSetInstallResultArchive(sets: [Api.StickerSetCovered])
case stickerSetInstallResultSuccess
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .stickerSetInstallResultArchive(let sets):
if boxed {
buffer.appendInt32(904138920)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(sets.count))
for item in sets {
item.serialize(buffer, true)
}
break
case .stickerSetInstallResultSuccess:
if boxed {
buffer.appendInt32(946083368)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .stickerSetInstallResultArchive(let sets):
return ("stickerSetInstallResultArchive", [("sets", sets as Any)])
case .stickerSetInstallResultSuccess:
return ("stickerSetInstallResultSuccess", [])
}
}
public static func parse_stickerSetInstallResultArchive(_ reader: BufferReader) -> StickerSetInstallResult? {
var _1: [Api.StickerSetCovered]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerSetCovered.self)
}
let _c1 = _1 != nil
if _c1 {
return Api.messages.StickerSetInstallResult.stickerSetInstallResultArchive(sets: _1!)
}
else {
return nil
}
}
public static func parse_stickerSetInstallResultSuccess(_ reader: BufferReader) -> StickerSetInstallResult? {
return Api.messages.StickerSetInstallResult.stickerSetInstallResultSuccess
}
}
}
public extension Api.messages {
enum Stickers: TypeConstructorDescription {
case stickers(hash: Int64, stickers: [Api.Document])
case stickersNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .stickers(let hash, let stickers):
if boxed {
buffer.appendInt32(816245886)
}
serializeInt64(hash, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(stickers.count))
for item in stickers {
item.serialize(buffer, true)
}
break
case .stickersNotModified:
if boxed {
buffer.appendInt32(-244016606)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .stickers(let hash, let stickers):
return ("stickers", [("hash", hash as Any), ("stickers", stickers as Any)])
case .stickersNotModified:
return ("stickersNotModified", [])
}
}
public static func parse_stickers(_ reader: BufferReader) -> Stickers? {
var _1: Int64?
_1 = reader.readInt64()
var _2: [Api.Document]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.messages.Stickers.stickers(hash: _1!, stickers: _2!)
}
else {
return nil
}
}
public static func parse_stickersNotModified(_ reader: BufferReader) -> Stickers? {
return Api.messages.Stickers.stickersNotModified
}
}
}

View File

@ -1,3 +1,115 @@
public extension Api.messages {
enum StickerSetInstallResult: TypeConstructorDescription {
case stickerSetInstallResultArchive(sets: [Api.StickerSetCovered])
case stickerSetInstallResultSuccess
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .stickerSetInstallResultArchive(let sets):
if boxed {
buffer.appendInt32(904138920)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(sets.count))
for item in sets {
item.serialize(buffer, true)
}
break
case .stickerSetInstallResultSuccess:
if boxed {
buffer.appendInt32(946083368)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .stickerSetInstallResultArchive(let sets):
return ("stickerSetInstallResultArchive", [("sets", sets as Any)])
case .stickerSetInstallResultSuccess:
return ("stickerSetInstallResultSuccess", [])
}
}
public static func parse_stickerSetInstallResultArchive(_ reader: BufferReader) -> StickerSetInstallResult? {
var _1: [Api.StickerSetCovered]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerSetCovered.self)
}
let _c1 = _1 != nil
if _c1 {
return Api.messages.StickerSetInstallResult.stickerSetInstallResultArchive(sets: _1!)
}
else {
return nil
}
}
public static func parse_stickerSetInstallResultSuccess(_ reader: BufferReader) -> StickerSetInstallResult? {
return Api.messages.StickerSetInstallResult.stickerSetInstallResultSuccess
}
}
}
public extension Api.messages {
enum Stickers: TypeConstructorDescription {
case stickers(hash: Int64, stickers: [Api.Document])
case stickersNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .stickers(let hash, let stickers):
if boxed {
buffer.appendInt32(816245886)
}
serializeInt64(hash, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(stickers.count))
for item in stickers {
item.serialize(buffer, true)
}
break
case .stickersNotModified:
if boxed {
buffer.appendInt32(-244016606)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .stickers(let hash, let stickers):
return ("stickers", [("hash", hash as Any), ("stickers", stickers as Any)])
case .stickersNotModified:
return ("stickersNotModified", [])
}
}
public static func parse_stickers(_ reader: BufferReader) -> Stickers? {
var _1: Int64?
_1 = reader.readInt64()
var _2: [Api.Document]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.messages.Stickers.stickers(hash: _1!, stickers: _2!)
}
else {
return nil
}
}
public static func parse_stickersNotModified(_ reader: BufferReader) -> Stickers? {
return Api.messages.Stickers.stickersNotModified
}
}
}
public extension Api.messages { public extension Api.messages {
enum TranscribedAudio: TypeConstructorDescription { enum TranscribedAudio: TypeConstructorDescription {
case transcribedAudio(flags: Int32, transcriptionId: Int64, text: String, trialRemainsNum: Int32?, trialRemainsUntilDate: Int32?) case transcribedAudio(flags: Int32, transcriptionId: Int64, text: String, trialRemainsNum: Int32?, trialRemainsUntilDate: Int32?)
@ -1580,213 +1692,3 @@ public extension Api.premium {
} }
} }
public extension Api.smsjobs {
enum EligibilityToJoin: TypeConstructorDescription {
case eligibleToJoin(termsUrl: String, monthlySentSms: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .eligibleToJoin(let termsUrl, let monthlySentSms):
if boxed {
buffer.appendInt32(-594852657)
}
serializeString(termsUrl, buffer: buffer, boxed: false)
serializeInt32(monthlySentSms, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .eligibleToJoin(let termsUrl, let monthlySentSms):
return ("eligibleToJoin", [("termsUrl", termsUrl as Any), ("monthlySentSms", monthlySentSms as Any)])
}
}
public static func parse_eligibleToJoin(_ reader: BufferReader) -> EligibilityToJoin? {
var _1: String?
_1 = parseString(reader)
var _2: Int32?
_2 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.smsjobs.EligibilityToJoin.eligibleToJoin(termsUrl: _1!, monthlySentSms: _2!)
}
else {
return nil
}
}
}
}
public extension Api.smsjobs {
enum Status: TypeConstructorDescription {
case status(flags: Int32, recentSent: Int32, recentSince: Int32, recentRemains: Int32, totalSent: Int32, totalSince: Int32, lastGiftSlug: String?, termsUrl: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .status(let flags, let recentSent, let recentSince, let recentRemains, let totalSent, let totalSince, let lastGiftSlug, let termsUrl):
if boxed {
buffer.appendInt32(720277905)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(recentSent, buffer: buffer, boxed: false)
serializeInt32(recentSince, buffer: buffer, boxed: false)
serializeInt32(recentRemains, buffer: buffer, boxed: false)
serializeInt32(totalSent, buffer: buffer, boxed: false)
serializeInt32(totalSince, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {serializeString(lastGiftSlug!, buffer: buffer, boxed: false)}
serializeString(termsUrl, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .status(let flags, let recentSent, let recentSince, let recentRemains, let totalSent, let totalSince, let lastGiftSlug, let termsUrl):
return ("status", [("flags", flags as Any), ("recentSent", recentSent as Any), ("recentSince", recentSince as Any), ("recentRemains", recentRemains as Any), ("totalSent", totalSent as Any), ("totalSince", totalSince as Any), ("lastGiftSlug", lastGiftSlug as Any), ("termsUrl", termsUrl as Any)])
}
}
public static func parse_status(_ reader: BufferReader) -> Status? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
_5 = reader.readInt32()
var _6: Int32?
_6 = reader.readInt32()
var _7: String?
if Int(_1!) & Int(1 << 1) != 0 {_7 = parseString(reader) }
var _8: String?
_8 = parseString(reader)
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.smsjobs.Status.status(flags: _1!, recentSent: _2!, recentSince: _3!, recentRemains: _4!, totalSent: _5!, totalSince: _6!, lastGiftSlug: _7, termsUrl: _8!)
}
else {
return nil
}
}
}
}
public extension Api.stats {
enum BroadcastRevenueStats: TypeConstructorDescription {
case broadcastRevenueStats(topHoursGraph: Api.StatsGraph, revenueGraph: Api.StatsGraph, currentBalance: Int64, availableBalance: Int64, overallRevenue: Int64, usdRate: Double)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .broadcastRevenueStats(let topHoursGraph, let revenueGraph, let currentBalance, let availableBalance, let overallRevenue, let usdRate):
if boxed {
buffer.appendInt32(-797226067)
}
topHoursGraph.serialize(buffer, true)
revenueGraph.serialize(buffer, true)
serializeInt64(currentBalance, buffer: buffer, boxed: false)
serializeInt64(availableBalance, buffer: buffer, boxed: false)
serializeInt64(overallRevenue, buffer: buffer, boxed: false)
serializeDouble(usdRate, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .broadcastRevenueStats(let topHoursGraph, let revenueGraph, let currentBalance, let availableBalance, let overallRevenue, let usdRate):
return ("broadcastRevenueStats", [("topHoursGraph", topHoursGraph as Any), ("revenueGraph", revenueGraph as Any), ("currentBalance", currentBalance as Any), ("availableBalance", availableBalance as Any), ("overallRevenue", overallRevenue as Any), ("usdRate", usdRate as Any)])
}
}
public static func parse_broadcastRevenueStats(_ reader: BufferReader) -> BroadcastRevenueStats? {
var _1: Api.StatsGraph?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _2: Api.StatsGraph?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _3: Int64?
_3 = reader.readInt64()
var _4: Int64?
_4 = reader.readInt64()
var _5: Int64?
_5 = reader.readInt64()
var _6: Double?
_6 = reader.readDouble()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.stats.BroadcastRevenueStats.broadcastRevenueStats(topHoursGraph: _1!, revenueGraph: _2!, currentBalance: _3!, availableBalance: _4!, overallRevenue: _5!, usdRate: _6!)
}
else {
return nil
}
}
}
}
public extension Api.stats {
enum BroadcastRevenueTransactions: TypeConstructorDescription {
case broadcastRevenueTransactions(count: Int32, transactions: [Api.BroadcastRevenueTransaction])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .broadcastRevenueTransactions(let count, let transactions):
if boxed {
buffer.appendInt32(-2028632986)
}
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(transactions.count))
for item in transactions {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .broadcastRevenueTransactions(let count, let transactions):
return ("broadcastRevenueTransactions", [("count", count as Any), ("transactions", transactions as Any)])
}
}
public static func parse_broadcastRevenueTransactions(_ reader: BufferReader) -> BroadcastRevenueTransactions? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.BroadcastRevenueTransaction]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.BroadcastRevenueTransaction.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.stats.BroadcastRevenueTransactions.broadcastRevenueTransactions(count: _1!, transactions: _2!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,213 @@
public extension Api.smsjobs {
enum EligibilityToJoin: TypeConstructorDescription {
case eligibleToJoin(termsUrl: String, monthlySentSms: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .eligibleToJoin(let termsUrl, let monthlySentSms):
if boxed {
buffer.appendInt32(-594852657)
}
serializeString(termsUrl, buffer: buffer, boxed: false)
serializeInt32(monthlySentSms, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .eligibleToJoin(let termsUrl, let monthlySentSms):
return ("eligibleToJoin", [("termsUrl", termsUrl as Any), ("monthlySentSms", monthlySentSms as Any)])
}
}
public static func parse_eligibleToJoin(_ reader: BufferReader) -> EligibilityToJoin? {
var _1: String?
_1 = parseString(reader)
var _2: Int32?
_2 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.smsjobs.EligibilityToJoin.eligibleToJoin(termsUrl: _1!, monthlySentSms: _2!)
}
else {
return nil
}
}
}
}
public extension Api.smsjobs {
enum Status: TypeConstructorDescription {
case status(flags: Int32, recentSent: Int32, recentSince: Int32, recentRemains: Int32, totalSent: Int32, totalSince: Int32, lastGiftSlug: String?, termsUrl: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .status(let flags, let recentSent, let recentSince, let recentRemains, let totalSent, let totalSince, let lastGiftSlug, let termsUrl):
if boxed {
buffer.appendInt32(720277905)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(recentSent, buffer: buffer, boxed: false)
serializeInt32(recentSince, buffer: buffer, boxed: false)
serializeInt32(recentRemains, buffer: buffer, boxed: false)
serializeInt32(totalSent, buffer: buffer, boxed: false)
serializeInt32(totalSince, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {serializeString(lastGiftSlug!, buffer: buffer, boxed: false)}
serializeString(termsUrl, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .status(let flags, let recentSent, let recentSince, let recentRemains, let totalSent, let totalSince, let lastGiftSlug, let termsUrl):
return ("status", [("flags", flags as Any), ("recentSent", recentSent as Any), ("recentSince", recentSince as Any), ("recentRemains", recentRemains as Any), ("totalSent", totalSent as Any), ("totalSince", totalSince as Any), ("lastGiftSlug", lastGiftSlug as Any), ("termsUrl", termsUrl as Any)])
}
}
public static func parse_status(_ reader: BufferReader) -> Status? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
_5 = reader.readInt32()
var _6: Int32?
_6 = reader.readInt32()
var _7: String?
if Int(_1!) & Int(1 << 1) != 0 {_7 = parseString(reader) }
var _8: String?
_8 = parseString(reader)
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.smsjobs.Status.status(flags: _1!, recentSent: _2!, recentSince: _3!, recentRemains: _4!, totalSent: _5!, totalSince: _6!, lastGiftSlug: _7, termsUrl: _8!)
}
else {
return nil
}
}
}
}
public extension Api.stats {
enum BroadcastRevenueStats: TypeConstructorDescription {
case broadcastRevenueStats(topHoursGraph: Api.StatsGraph, revenueGraph: Api.StatsGraph, currentBalance: Int64, availableBalance: Int64, overallRevenue: Int64, usdRate: Double)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .broadcastRevenueStats(let topHoursGraph, let revenueGraph, let currentBalance, let availableBalance, let overallRevenue, let usdRate):
if boxed {
buffer.appendInt32(-797226067)
}
topHoursGraph.serialize(buffer, true)
revenueGraph.serialize(buffer, true)
serializeInt64(currentBalance, buffer: buffer, boxed: false)
serializeInt64(availableBalance, buffer: buffer, boxed: false)
serializeInt64(overallRevenue, buffer: buffer, boxed: false)
serializeDouble(usdRate, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .broadcastRevenueStats(let topHoursGraph, let revenueGraph, let currentBalance, let availableBalance, let overallRevenue, let usdRate):
return ("broadcastRevenueStats", [("topHoursGraph", topHoursGraph as Any), ("revenueGraph", revenueGraph as Any), ("currentBalance", currentBalance as Any), ("availableBalance", availableBalance as Any), ("overallRevenue", overallRevenue as Any), ("usdRate", usdRate as Any)])
}
}
public static func parse_broadcastRevenueStats(_ reader: BufferReader) -> BroadcastRevenueStats? {
var _1: Api.StatsGraph?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _2: Api.StatsGraph?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _3: Int64?
_3 = reader.readInt64()
var _4: Int64?
_4 = reader.readInt64()
var _5: Int64?
_5 = reader.readInt64()
var _6: Double?
_6 = reader.readDouble()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.stats.BroadcastRevenueStats.broadcastRevenueStats(topHoursGraph: _1!, revenueGraph: _2!, currentBalance: _3!, availableBalance: _4!, overallRevenue: _5!, usdRate: _6!)
}
else {
return nil
}
}
}
}
public extension Api.stats {
enum BroadcastRevenueTransactions: TypeConstructorDescription {
case broadcastRevenueTransactions(count: Int32, transactions: [Api.BroadcastRevenueTransaction])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .broadcastRevenueTransactions(let count, let transactions):
if boxed {
buffer.appendInt32(-2028632986)
}
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(transactions.count))
for item in transactions {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .broadcastRevenueTransactions(let count, let transactions):
return ("broadcastRevenueTransactions", [("count", count as Any), ("transactions", transactions as Any)])
}
}
public static func parse_broadcastRevenueTransactions(_ reader: BufferReader) -> BroadcastRevenueTransactions? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.BroadcastRevenueTransaction]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.BroadcastRevenueTransaction.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.stats.BroadcastRevenueTransactions.broadcastRevenueTransactions(count: _1!, transactions: _2!)
}
else {
return nil
}
}
}
}
public extension Api.stats { public extension Api.stats {
enum BroadcastRevenueWithdrawalUrl: TypeConstructorDescription { enum BroadcastRevenueWithdrawalUrl: TypeConstructorDescription {
case broadcastRevenueWithdrawalUrl(url: String) case broadcastRevenueWithdrawalUrl(url: String)
@ -1522,55 +1732,3 @@ public extension Api.updates {
} }
} }
public extension Api.updates {
enum State: TypeConstructorDescription {
case state(pts: Int32, qts: Int32, date: Int32, seq: Int32, unreadCount: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .state(let pts, let qts, let date, let seq, let unreadCount):
if boxed {
buffer.appendInt32(-1519637954)
}
serializeInt32(pts, buffer: buffer, boxed: false)
serializeInt32(qts, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(seq, buffer: buffer, boxed: false)
serializeInt32(unreadCount, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .state(let pts, let qts, let date, let seq, let unreadCount):
return ("state", [("pts", pts as Any), ("qts", qts as Any), ("date", date as Any), ("seq", seq as Any), ("unreadCount", unreadCount as Any)])
}
}
public static func parse_state(_ reader: BufferReader) -> State? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
_5 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.updates.State.state(pts: _1!, qts: _2!, date: _3!, seq: _4!, unreadCount: _5!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,55 @@
public extension Api.updates {
enum State: TypeConstructorDescription {
case state(pts: Int32, qts: Int32, date: Int32, seq: Int32, unreadCount: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .state(let pts, let qts, let date, let seq, let unreadCount):
if boxed {
buffer.appendInt32(-1519637954)
}
serializeInt32(pts, buffer: buffer, boxed: false)
serializeInt32(qts, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt32(seq, buffer: buffer, boxed: false)
serializeInt32(unreadCount, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .state(let pts, let qts, let date, let seq, let unreadCount):
return ("state", [("pts", pts as Any), ("qts", qts as Any), ("date", date as Any), ("seq", seq as Any), ("unreadCount", unreadCount as Any)])
}
}
public static func parse_state(_ reader: BufferReader) -> State? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
_5 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.updates.State.state(pts: _1!, qts: _2!, date: _3!, seq: _4!, unreadCount: _5!)
}
else {
return nil
}
}
}
}
public extension Api.upload { public extension Api.upload {
enum CdnFile: TypeConstructorDescription { enum CdnFile: TypeConstructorDescription {
case cdnFile(bytes: Buffer) case cdnFile(bytes: Buffer)

View File

@ -2043,6 +2043,23 @@ public extension Api.functions.auth {
}) })
} }
} }
public extension Api.functions.auth {
static func reportMissingCode(phoneNumber: String, phoneCodeHash: String, mnc: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer()
buffer.appendInt32(-878841866)
serializeString(phoneNumber, buffer: buffer, boxed: false)
serializeString(phoneCodeHash, buffer: buffer, boxed: false)
serializeString(mnc, buffer: buffer, boxed: false)
return (FunctionDescription(name: "auth.reportMissingCode", parameters: [("phoneNumber", String(describing: phoneNumber)), ("phoneCodeHash", String(describing: phoneCodeHash)), ("mnc", String(describing: mnc))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
let reader = BufferReader(buffer)
var result: Api.Bool?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Bool
}
return result
})
}
}
public extension Api.functions.auth { public extension Api.functions.auth {
static func requestFirebaseSms(flags: Int32, phoneNumber: String, phoneCodeHash: String, safetyNetToken: String?, iosPushSecret: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) { static func requestFirebaseSms(flags: Int32, phoneNumber: String, phoneCodeHash: String, safetyNetToken: String?, iosPushSecret: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer() let buffer = Buffer()

View File

@ -1325,3 +1325,17 @@ public func resetAuthorizationState(account: UnauthorizedAccount, to value: Auth
} }
} }
} }
public enum ReportMissingCodeError {
case generic
}
func _internal_reportMissingCode(network: Network, phoneNumber: String, phoneCodeHash: String, mnc: String) -> Signal<Never, ReportMissingCodeError> {
return network.request(Api.functions.auth.reportMissingCode(phoneNumber: phoneNumber, phoneCodeHash: phoneCodeHash, mnc: mnc))
|> mapError { error -> ReportMissingCodeError in
return .generic
}
|> mapToSignal { result -> Signal<Never, ReportMissingCodeError> in
return .complete()
}
}

View File

@ -38,6 +38,10 @@ extension SentAuthorizationCodeType {
self = .fragment(url: url, length: length) self = .fragment(url: url, length: length)
case let .sentCodeTypeFirebaseSms(_, _, _, pushTimeout, length): case let .sentCodeTypeFirebaseSms(_, _, _, pushTimeout, length):
self = .firebase(pushTimeout: pushTimeout, length: length) self = .firebase(pushTimeout: pushTimeout, length: length)
case let .sentCodeTypeSmsWord(_, beginning):
self = .word(startsWith: beginning)
case let .sentCodeTypeSmsPhrase(_, beginning):
self = .phrase(startsWith: beginning)
} }
} }
} }

View File

@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
public class Serialization: NSObject, MTSerialization { public class Serialization: NSObject, MTSerialization {
public func currentLayer() -> UInt { public func currentLayer() -> UInt {
return 178 return 179
} }
public func parseMessage(_ data: Data!) -> Any! { public func parseMessage(_ data: Data!) -> Any! {

View File

@ -10,6 +10,8 @@ private enum SentAuthorizationCodeTypeValue: Int32 {
case emailSetupRequired = 6 case emailSetupRequired = 6
case fragment = 7 case fragment = 7
case firebase = 8 case firebase = 8
case word = 9
case phrase = 10
} }
public enum SentAuthorizationCodeType: PostboxCoding, Equatable { public enum SentAuthorizationCodeType: PostboxCoding, Equatable {
@ -22,6 +24,8 @@ public enum SentAuthorizationCodeType: PostboxCoding, Equatable {
case emailSetupRequired(appleSignInAllowed: Bool) case emailSetupRequired(appleSignInAllowed: Bool)
case fragment(url: String, length: Int32) case fragment(url: String, length: Int32)
case firebase(pushTimeout: Int32?, length: Int32) case firebase(pushTimeout: Int32?, length: Int32)
case word(startsWith: String?)
case phrase(startsWith: String?)
public init(decoder: PostboxDecoder) { public init(decoder: PostboxDecoder) {
switch decoder.decodeInt32ForKey("v", orElse: 0) { switch decoder.decodeInt32ForKey("v", orElse: 0) {
@ -43,6 +47,10 @@ public enum SentAuthorizationCodeType: PostboxCoding, Equatable {
self = .fragment(url: decoder.decodeStringForKey("u", orElse: ""), length: decoder.decodeInt32ForKey("l", orElse: 0)) self = .fragment(url: decoder.decodeStringForKey("u", orElse: ""), length: decoder.decodeInt32ForKey("l", orElse: 0))
case SentAuthorizationCodeTypeValue.firebase.rawValue: case SentAuthorizationCodeTypeValue.firebase.rawValue:
self = .firebase(pushTimeout: decoder.decodeOptionalInt32ForKey("pushTimeout"), length: decoder.decodeInt32ForKey("length", orElse: 0)) self = .firebase(pushTimeout: decoder.decodeOptionalInt32ForKey("pushTimeout"), length: decoder.decodeInt32ForKey("length", orElse: 0))
case SentAuthorizationCodeTypeValue.word.rawValue:
self = .word(startsWith: decoder.decodeOptionalStringForKey("w"))
case SentAuthorizationCodeTypeValue.phrase.rawValue:
self = .phrase(startsWith: decoder.decodeOptionalStringForKey("ph"))
default: default:
preconditionFailure() preconditionFailure()
} }
@ -97,6 +105,20 @@ public enum SentAuthorizationCodeType: PostboxCoding, Equatable {
encoder.encodeNil(forKey: "pushTimeout") encoder.encodeNil(forKey: "pushTimeout")
} }
encoder.encodeInt32(length, forKey: "length") encoder.encodeInt32(length, forKey: "length")
case let .word(startsWith):
encoder.encodeInt32(SentAuthorizationCodeTypeValue.word.rawValue, forKey: "v")
if let startsWith = startsWith {
encoder.encodeString(startsWith, forKey: "w")
} else {
encoder.encodeNil(forKey: "w")
}
case let .phrase(startsWith):
encoder.encodeInt32(SentAuthorizationCodeTypeValue.phrase.rawValue, forKey: "v")
if let startsWith = startsWith {
encoder.encodeString(startsWith, forKey: "ph")
} else {
encoder.encodeNil(forKey: "ph")
}
} }
} }
} }

View File

@ -52,6 +52,10 @@ public extension TelegramEngineUnauthorized {
return _internal_uploadedPeerVideo(postbox: self.account.postbox, network: self.account.network, messageMediaPreuploadManager: nil, resource: resource) return _internal_uploadedPeerVideo(postbox: self.account.postbox, network: self.account.network, messageMediaPreuploadManager: nil, resource: resource)
} }
public func reportMissingCode(phoneNumber: String, phoneCodeHash: String, mnc: String) -> Signal<Never, ReportMissingCodeError> {
return _internal_reportMissingCode(network: self.account.network, phoneNumber: phoneNumber, phoneCodeHash: phoneCodeHash, mnc: mnc)
}
public func state() -> Signal<TelegramEngineAuthorizationState?, NoError> { public func state() -> Signal<TelegramEngineAuthorizationState?, NoError> {
return self.account.postbox.stateView() return self.account.postbox.stateView()
|> map { view -> TelegramEngineAuthorizationState? in |> map { view -> TelegramEngineAuthorizationState? in
@ -202,6 +206,10 @@ public extension TelegramEngine {
public func invalidateLoginCodes(codes: [String]) -> Signal<Never, NoError> { public func invalidateLoginCodes(codes: [String]) -> Signal<Never, NoError> {
return _internal_invalidateLoginCodes(network: self.account.network, codes: codes) return _internal_invalidateLoginCodes(network: self.account.network, codes: codes)
} }
public func reportMissingCode(phoneNumber: String, phoneCodeHash: String, mnc: String) -> Signal<Never, ReportMissingCodeError> {
return _internal_reportMissingCode(network: self.account.network, phoneNumber: phoneNumber, phoneCodeHash: phoneCodeHash, mnc: mnc)
}
} }
} }