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

@@ -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)
case let .sentCodeTypeFirebaseSms(_, _, _, pushTimeout, 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 func currentLayer() -> UInt {
return 178
return 179
}
public func parseMessage(_ data: Data!) -> Any! {

View File

@@ -10,6 +10,8 @@ private enum SentAuthorizationCodeTypeValue: Int32 {
case emailSetupRequired = 6
case fragment = 7
case firebase = 8
case word = 9
case phrase = 10
}
public enum SentAuthorizationCodeType: PostboxCoding, Equatable {
@@ -22,6 +24,8 @@ public enum SentAuthorizationCodeType: PostboxCoding, Equatable {
case emailSetupRequired(appleSignInAllowed: Bool)
case fragment(url: String, length: Int32)
case firebase(pushTimeout: Int32?, length: Int32)
case word(startsWith: String?)
case phrase(startsWith: String?)
public init(decoder: PostboxDecoder) {
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))
case SentAuthorizationCodeTypeValue.firebase.rawValue:
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:
preconditionFailure()
}
@@ -97,6 +105,20 @@ public enum SentAuthorizationCodeType: PostboxCoding, Equatable {
encoder.encodeNil(forKey: "pushTimeout")
}
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)
}
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> {
return self.account.postbox.stateView()
|> map { view -> TelegramEngineAuthorizationState? in
@@ -202,6 +206,10 @@ public extension TelegramEngine {
public func invalidateLoginCodes(codes: [String]) -> Signal<Never, NoError> {
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)
}
}
}