Fix API [skip ci]

This commit is contained in:
Peter
2019-07-18 23:30:59 +01:00
parent 200ee290b2
commit 8a71de3700
10 changed files with 91 additions and 118 deletions

View File

@@ -147,7 +147,7 @@ extension UnauthorizedAccountTermsOfService {
public enum UnauthorizedAccountStateContents: PostboxCoding, Equatable {
case empty
case phoneEntry(countryCode: Int32, number: String)
case confirmationCodeEntry(number: String, type: SentAuthorizationCodeType, hash: String, timeout: Int32?, nextType: AuthorizationCodeNextType?, termsOfService: (UnauthorizedAccountTermsOfService, Bool)?, syncContacts: Bool)
case confirmationCodeEntry(number: String, type: SentAuthorizationCodeType, hash: String, timeout: Int32?, nextType: AuthorizationCodeNextType?, syncContacts: Bool)
case passwordEntry(hint: String, number: String?, code: String?, suggestReset: Bool, syncContacts: Bool)
case passwordRecovery(hint: String, number: String?, code: String?, emailPattern: String, syncContacts: Bool)
case awaitingAccountReset(protectedUntil: Int32, number: String?, syncContacts: Bool)
@@ -164,11 +164,7 @@ public enum UnauthorizedAccountStateContents: PostboxCoding, Equatable {
if let value = decoder.decodeOptionalInt32ForKey("nt") {
nextType = AuthorizationCodeNextType(rawValue: value)
}
var termsOfService: (UnauthorizedAccountTermsOfService, Bool)?
if let termsValue = decoder.decodeObjectForKey("tos", decoder: { UnauthorizedAccountTermsOfService(decoder: $0) }) as? UnauthorizedAccountTermsOfService {
termsOfService = (termsValue, decoder.decodeInt32ForKey("tose", orElse: 0) != 0)
}
self = .confirmationCodeEntry(number: decoder.decodeStringForKey("num", orElse: ""), type: decoder.decodeObjectForKey("t", decoder: { SentAuthorizationCodeType(decoder: $0) }) as! SentAuthorizationCodeType, hash: decoder.decodeStringForKey("h", orElse: ""), timeout: decoder.decodeOptionalInt32ForKey("tm"), nextType: nextType, termsOfService: termsOfService, syncContacts: decoder.decodeInt32ForKey("syncContacts", orElse: 1) != 0)
self = .confirmationCodeEntry(number: decoder.decodeStringForKey("num", orElse: ""), type: decoder.decodeObjectForKey("t", decoder: { SentAuthorizationCodeType(decoder: $0) }) as! SentAuthorizationCodeType, hash: decoder.decodeStringForKey("h", orElse: ""), timeout: decoder.decodeOptionalInt32ForKey("tm"), nextType: nextType, syncContacts: decoder.decodeInt32ForKey("syncContacts", orElse: 1) != 0)
case UnauthorizedAccountStateContentsValue.passwordEntry.rawValue:
self = .passwordEntry(hint: decoder.decodeStringForKey("h", orElse: ""), number: decoder.decodeOptionalStringForKey("n"), code: decoder.decodeOptionalStringForKey("c"), suggestReset: decoder.decodeInt32ForKey("suggestReset", orElse: 0) != 0, syncContacts: decoder.decodeInt32ForKey("syncContacts", orElse: 1) != 0)
case UnauthorizedAccountStateContentsValue.passwordRecovery.rawValue:
@@ -191,7 +187,7 @@ public enum UnauthorizedAccountStateContents: PostboxCoding, Equatable {
encoder.encodeInt32(UnauthorizedAccountStateContentsValue.phoneEntry.rawValue, forKey: "v")
encoder.encodeInt32(countryCode, forKey: "cc")
encoder.encodeString(number, forKey: "n")
case let .confirmationCodeEntry(number, type, hash, timeout, nextType, termsOfService, syncContacts):
case let .confirmationCodeEntry(number, type, hash, timeout, nextType, syncContacts):
encoder.encodeInt32(UnauthorizedAccountStateContentsValue.confirmationCodeEntry.rawValue, forKey: "v")
encoder.encodeString(number, forKey: "num")
encoder.encodeObject(type, forKey: "t")
@@ -206,12 +202,6 @@ public enum UnauthorizedAccountStateContents: PostboxCoding, Equatable {
} else {
encoder.encodeNil(forKey: "nt")
}
if let (termsOfService, exclusive) = termsOfService {
encoder.encodeObject(termsOfService, forKey: "tos")
encoder.encodeInt32(exclusive ? 1 : 0, forKey: "tose")
} else {
encoder.encodeNil(forKey: "tos")
}
encoder.encodeInt32(syncContacts ? 1 : 0, forKey: "syncContacts")
case let .passwordEntry(hint, number, code, suggestReset, syncContacts):
encoder.encodeInt32(UnauthorizedAccountStateContentsValue.passwordEntry.rawValue, forKey: "v")
@@ -282,8 +272,8 @@ public enum UnauthorizedAccountStateContents: PostboxCoding, Equatable {
} else {
return false
}
case let .confirmationCodeEntry(lhsNumber, lhsType, lhsHash, lhsTimeout, lhsNextType, lhsTermsOfService, lhsSyncContacts):
if case let .confirmationCodeEntry(rhsNumber, rhsType, rhsHash, rhsTimeout, rhsNextType, rhsTermsOfService, rhsSyncContacts) = rhs {
case let .confirmationCodeEntry(lhsNumber, lhsType, lhsHash, lhsTimeout, lhsNextType, lhsSyncContacts):
if case let .confirmationCodeEntry(rhsNumber, rhsType, rhsHash, rhsTimeout, rhsNextType, rhsSyncContacts) = rhs {
if lhsNumber != rhsNumber {
return false
}
@@ -299,12 +289,6 @@ public enum UnauthorizedAccountStateContents: PostboxCoding, Equatable {
if lhsNextType != rhsNextType {
return false
}
if lhsTermsOfService?.0 != rhsTermsOfService?.0 {
return false
}
if lhsTermsOfService?.1 != rhsTermsOfService?.1 {
return false
}
if lhsSyncContacts != rhsSyncContacts {
return false
}

View File

@@ -83,22 +83,13 @@ public func sendAuthorizationCode(accountManager: AccountManager, account: Unaut
|> mapToSignal { (sentCode, account) -> Signal<UnauthorizedAccount, AuthorizationCodeRequestError> in
return account.postbox.transaction { transaction -> UnauthorizedAccount in
switch sentCode {
case let .sentCode(_, type, phoneCodeHash, nextType, timeout, termsOfService):
case let .sentCode(_, type, phoneCodeHash, nextType, timeout):
var parsedNextType: AuthorizationCodeNextType?
if let nextType = nextType {
parsedNextType = AuthorizationCodeNextType(apiType: nextType)
}
var explicitTerms = false
if let termsOfService = termsOfService {
switch termsOfService {
case let .termsOfService(value):
if (value.flags & (1 << 0)) != 0 {
explicitTerms = true
}
}
}
transaction.setState(UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .confirmationCodeEntry(number: phoneNumber, type: SentAuthorizationCodeType(apiType: type), hash: phoneCodeHash, timeout: timeout, nextType: parsedNextType, termsOfService: termsOfService.flatMap(UnauthorizedAccountTermsOfService.init(apiTermsOfService:)).flatMap({ ($0, explicitTerms) }), syncContacts: syncContacts)))
transaction.setState(UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .confirmationCodeEntry(number: phoneNumber, type: SentAuthorizationCodeType(apiType: type), hash: phoneCodeHash, timeout: timeout, nextType: parsedNextType, syncContacts: syncContacts)))
}
return account
}
@@ -112,7 +103,7 @@ public func resendAuthorizationCode(account: UnauthorizedAccount) -> Signal<Void
return account.postbox.transaction { transaction -> Signal<Void, AuthorizationCodeRequestError> in
if let state = transaction.getState() as? UnauthorizedAccountState {
switch state.contents {
case let .confirmationCodeEntry(number, _, hash, _, nextType, _, syncContacts):
case let .confirmationCodeEntry(number, _, hash, _, nextType, syncContacts):
if nextType != nil {
return account.network.request(Api.functions.auth.resendCode(phoneNumber: number, phoneCodeHash: hash), automaticFloodWait: false)
|> mapError { error -> AuthorizationCodeRequestError in
@@ -131,24 +122,14 @@ public func resendAuthorizationCode(account: UnauthorizedAccount) -> Signal<Void
|> mapToSignal { sentCode -> Signal<Void, AuthorizationCodeRequestError> in
return account.postbox.transaction { transaction -> Void in
switch sentCode {
case let .sentCode(_, type, phoneCodeHash, nextType, timeout, termsOfService):
case let .sentCode(_, type, phoneCodeHash, nextType, timeout):
var parsedNextType: AuthorizationCodeNextType?
if let nextType = nextType {
parsedNextType = AuthorizationCodeNextType(apiType: nextType)
}
var explicitTerms = false
if let termsOfService = termsOfService {
switch termsOfService {
case let .termsOfService(value):
if (value.flags & (1 << 0)) != 0 {
explicitTerms = true
}
}
}
transaction.setState(UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .confirmationCodeEntry(number: number, type: SentAuthorizationCodeType(apiType: type), hash: phoneCodeHash, timeout: timeout, nextType: parsedNextType, termsOfService: termsOfService.flatMap(UnauthorizedAccountTermsOfService.init(apiTermsOfService:)).flatMap({ ($0, explicitTerms) }), syncContacts: syncContacts)))
transaction.setState(UnauthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, contents: .confirmationCodeEntry(number: number, type: SentAuthorizationCodeType(apiType: type), hash: phoneCodeHash, timeout: timeout, nextType: parsedNextType, syncContacts: syncContacts)))
}
} |> mapError { _ -> AuthorizationCodeRequestError in return .generic(info: nil) }
@@ -199,7 +180,7 @@ public func authorizeWithCode(accountManager: AccountManager, account: Unauthori
return account.postbox.transaction { transaction -> Signal<AuthorizeWithCodeResult, AuthorizationCodeVerificationError> in
if let state = transaction.getState() as? UnauthorizedAccountState {
switch state.contents {
case let .confirmationCodeEntry(number, _, hash, _, _, _, syncContacts):
case let .confirmationCodeEntry(number, _, hash, _, _, syncContacts):
return account.network.request(Api.functions.auth.signIn(phoneNumber: number, phoneCodeHash: hash, phoneCode: code), automaticFloodWait: false)
|> map { authorization in
return .authorization(authorization)
@@ -245,15 +226,17 @@ public func authorizeWithCode(accountManager: AccountManager, account: Unauthori
return .single(.loggedIn)
case let .authorization(authorization):
switch authorization {
case let .authorization(_, _, user):
let user = TelegramUser(user: user)
let state = AuthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, peerId: user.id, state: nil)
initializedAppSettingsAfterLogin(transaction: transaction, appVersion: account.networkArguments.appVersion, syncContacts: syncContacts)
transaction.setState(state)
}
return accountManager.transaction { transaction -> AuthorizeWithCodeResult in
switchToAuthorizedAccount(transaction: transaction, account: account)
return .loggedIn
case let .authorization(_, _, user):
let user = TelegramUser(user: user)
let state = AuthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, peerId: user.id, state: nil)
initializedAppSettingsAfterLogin(transaction: transaction, appVersion: account.networkArguments.appVersion, syncContacts: syncContacts)
transaction.setState(state)
return accountManager.transaction { transaction -> AuthorizeWithCodeResult in
switchToAuthorizedAccount(transaction: transaction, account: account)
return .loggedIn
}
case let .authorizationSignUpRequired(_, termsOfService):
return .single(.signUp(AuthorizationSignUpData(number: number, codeHash: hash, code: code, termsOfService: termsOfService.flatMap(UnauthorizedAccountTermsOfService.init(apiTermsOfService:)), syncContacts: syncContacts)))
}
}
}
@@ -302,19 +285,21 @@ public func authorizeWithPassword(accountManager: AccountManager, account: Unaut
|> mapToSignal { result -> Signal<Void, AuthorizationPasswordVerificationError> in
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
switch result {
case let .authorization(_, _, user):
let user = TelegramUser(user: user)
let state = AuthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, peerId: user.id, state: nil)
/*transaction.updatePeersInternal([user], update: { current, peer -> Peer? in
return peer
})*/
initializedAppSettingsAfterLogin(transaction: transaction, appVersion: account.networkArguments.appVersion, syncContacts: syncContacts)
transaction.setState(state)
case let .authorization(_, _, user):
let user = TelegramUser(user: user)
let state = AuthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, peerId: user.id, state: nil)
/*transaction.updatePeersInternal([user], update: { current, peer -> Peer? in
return peer
})*/
initializedAppSettingsAfterLogin(transaction: transaction, appVersion: account.networkArguments.appVersion, syncContacts: syncContacts)
transaction.setState(state)
return accountManager.transaction { transaction -> Void in
switchToAuthorizedAccount(transaction: transaction, account: account)
}
return accountManager.transaction { transaction -> Void in
switchToAuthorizedAccount(transaction: transaction, account: account)
}
case .authorizationSignUpRequired:
return .complete()
}
}
|> switchToLatest
|> mapError { _ -> AuthorizationPasswordVerificationError in
@@ -377,17 +362,19 @@ public func performPasswordRecovery(accountManager: AccountManager, account: Una
|> mapToSignal { result -> Signal<Void, PasswordRecoveryError> in
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
switch result {
case let .authorization(_, _, user):
let user = TelegramUser(user: user)
let state = AuthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, peerId: user.id, state: nil)
/*transaction.updatePeersInternal([user], update: { current, peer -> Peer? in
return peer
})*/
initializedAppSettingsAfterLogin(transaction: transaction, appVersion: account.networkArguments.appVersion, syncContacts: syncContacts)
transaction.setState(state)
return accountManager.transaction { transaction -> Void in
switchToAuthorizedAccount(transaction: transaction, account: account)
}
case let .authorization(_, _, user):
let user = TelegramUser(user: user)
let state = AuthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, peerId: user.id, state: nil)
/*transaction.updatePeersInternal([user], update: { current, peer -> Peer? in
return peer
})*/
initializedAppSettingsAfterLogin(transaction: transaction, appVersion: account.networkArguments.appVersion, syncContacts: syncContacts)
transaction.setState(state)
return accountManager.transaction { transaction -> Void in
switchToAuthorizedAccount(transaction: transaction, account: account)
}
case .authorizationSignUpRequired:
return .complete()
}
}
|> switchToLatest
@@ -454,8 +441,8 @@ public enum SignUpError {
public func signUpWithName(accountManager: AccountManager, account: UnauthorizedAccount, firstName: String, lastName: String, avatarData: Data?) -> Signal<Void, SignUpError> {
return account.postbox.transaction { transaction -> Signal<Void, SignUpError> in
if let state = transaction.getState() as? UnauthorizedAccountState, case let .signUp(number, codeHash, code, _, _, _, syncContacts) = state.contents {
return account.network.request(Api.functions.auth.signUp(phoneNumber: number, phoneCodeHash: codeHash, phoneCode: code, firstName: firstName, lastName: lastName))
if let state = transaction.getState() as? UnauthorizedAccountState, case let .signUp(number, codeHash, _, _, _, _, syncContacts) = state.contents {
return account.network.request(Api.functions.auth.signUp(phoneNumber: number, phoneCodeHash: codeHash, firstName: firstName, lastName: lastName))
|> mapError { error -> SignUpError in
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
return .limitExceeded
@@ -471,45 +458,47 @@ public func signUpWithName(accountManager: AccountManager, account: Unauthorized
}
|> mapToSignal { result -> Signal<Void, SignUpError> in
switch result {
case let .authorization(_, _, user):
let user = TelegramUser(user: user)
let appliedState = account.postbox.transaction { transaction -> Void in
let state = AuthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, peerId: user.id, state: nil)
if let hole = account.postbox.seedConfiguration.initializeChatListWithHole.topLevel {
transaction.replaceChatListHole(groupId: .root, index: hole.index, hole: nil)
}
initializedAppSettingsAfterLogin(transaction: transaction, appVersion: account.networkArguments.appVersion, syncContacts: syncContacts)
transaction.setState(state)
case let .authorization(_, _, user):
let user = TelegramUser(user: user)
let appliedState = account.postbox.transaction { transaction -> Void in
let state = AuthorizedAccountState(isTestingEnvironment: account.testingEnvironment, masterDatacenterId: account.masterDatacenterId, peerId: user.id, state: nil)
if let hole = account.postbox.seedConfiguration.initializeChatListWithHole.topLevel {
transaction.replaceChatListHole(groupId: .root, index: hole.index, hole: nil)
}
|> introduceError(SignUpError.self)
let switchedAccounts = accountManager.transaction { transaction -> Void in
switchToAuthorizedAccount(transaction: transaction, account: account)
initializedAppSettingsAfterLogin(transaction: transaction, appVersion: account.networkArguments.appVersion, syncContacts: syncContacts)
transaction.setState(state)
}
|> introduceError(SignUpError.self)
if let avatarData = avatarData {
let resource = LocalFileMediaResource(fileId: arc4random64())
account.postbox.mediaBox.storeResourceData(resource.id, data: avatarData)
return updatePeerPhotoInternal(postbox: account.postbox, network: account.network, stateManager: nil, accountPeerId: user.id, peer: .single(user), photo: uploadedPeerPhoto(postbox: account.postbox, network: account.network, resource: resource), mapResourceToAvatarSizes: { _, _ in .single([:]) })
let switchedAccounts = accountManager.transaction { transaction -> Void in
switchToAuthorizedAccount(transaction: transaction, account: account)
}
|> introduceError(SignUpError.self)
if let avatarData = avatarData {
let resource = LocalFileMediaResource(fileId: arc4random64())
account.postbox.mediaBox.storeResourceData(resource.id, data: avatarData)
return updatePeerPhotoInternal(postbox: account.postbox, network: account.network, stateManager: nil, accountPeerId: user.id, peer: .single(user), photo: uploadedPeerPhoto(postbox: account.postbox, network: account.network, resource: resource), mapResourceToAvatarSizes: { _, _ in .single([:]) })
|> `catch` { _ -> Signal<UpdatePeerPhotoStatus, SignUpError> in
return .complete()
}
|> mapToSignal { result -> Signal<Void, SignUpError> in
switch result {
case .complete:
return .complete()
case .progress:
return .never()
case .complete:
return .complete()
case .progress:
return .never()
}
}
|> then(appliedState)
|> then(switchedAccounts)
} else {
return appliedState
} else {
return appliedState
|> then(switchedAccounts)
}
}
case .authorizationSignUpRequired:
return .fail(.generic)
}
}
} else {

View File

@@ -372,7 +372,7 @@ public func sendBotPaymentForm(account: Account, messageId: MessageId, validated
case let .paymentResult(updates):
account.stateManager.addUpdates(updates)
return .done
case let .paymentVerficationNeeded(url):
case let .paymentVerificationNeeded(url):
return .externalVerificationRequired(url: url)
}
}

View File

@@ -176,13 +176,13 @@ extension ChannelParticipant {
switch apiParticipant {
case let .channelParticipant(userId, date):
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedAt: date, adminInfo: nil, banInfo: nil)
case let .channelParticipantCreator(userId):
case let .channelParticipantCreator(_, userId, _):
self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId))
case let .channelParticipantBanned(flags, userId, restrictedBy, date, bannedRights):
let hasLeft = (flags & (1 << 0)) != 0
let banInfo = ChannelParticipantBannedInfo(rights: TelegramChatBannedRights(apiBannedRights: bannedRights), restrictedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: restrictedBy), timestamp: date, isMember: !hasLeft)
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedAt: date, adminInfo: nil, banInfo: banInfo)
case let .channelParticipantAdmin(flags, userId, _, promotedBy, date, adminRights):
case let .channelParticipantAdmin(flags, userId, _, promotedBy, date, adminRights, _):
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedAt: date, adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: promotedBy), canBeEditedByAccountPeer: (flags & (1 << 0)) != 0), banInfo: nil)
case let .channelParticipantSelf(userId, _, date):
self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedAt: date, adminInfo: nil, banInfo: nil)

View File

@@ -38,7 +38,7 @@ public func requestCancelAccountResetData(network: Network, hash: String) -> Sig
}
|> map { sentCode -> CancelAccountResetData in
switch sentCode {
case let .sentCode(_, type, phoneCodeHash, nextType, timeout, _):
case let .sentCode(_, type, phoneCodeHash, nextType, timeout):
var parsedNextType: AuthorizationCodeNextType?
if let nextType = nextType {
parsedNextType = AuthorizationCodeNextType(apiType: nextType)
@@ -59,7 +59,7 @@ public func requestNextCancelAccountResetOption(network: Network, phoneNumber: S
}
|> map { sentCode -> CancelAccountResetData in
switch sentCode {
case let .sentCode(_, type, phoneCodeHash, nextType, timeout, _):
case let .sentCode(_, type, phoneCodeHash, nextType, timeout):
var parsedNextType: AuthorizationCodeNextType?
if let nextType = nextType {
parsedNextType = AuthorizationCodeNextType(apiType: nextType)

View File

@@ -60,7 +60,7 @@ public func requestChangeAccountPhoneNumberVerification(account: Account, phoneN
}
|> map { sentCode -> ChangeAccountPhoneNumberData in
switch sentCode {
case let .sentCode(_, type, phoneCodeHash, nextType, timeout, _):
case let .sentCode(_, type, phoneCodeHash, nextType, timeout):
var parsedNextType: AuthorizationCodeNextType?
if let nextType = nextType {
parsedNextType = AuthorizationCodeNextType(apiType: nextType)
@@ -85,7 +85,7 @@ public func requestNextChangeAccountPhoneNumberVerification(account: Account, ph
}
|> map { sentCode -> ChangeAccountPhoneNumberData in
switch sentCode {
case let .sentCode(_, type, phoneCodeHash, nextType, timeout, _):
case let .sentCode(_, type, phoneCodeHash, nextType, timeout):
var parsedNextType: AuthorizationCodeNextType?
if let nextType = nextType {
parsedNextType = AuthorizationCodeNextType(apiType: nextType)

View File

@@ -72,9 +72,9 @@ public func channelAdminIds(postbox: Postbox, network: Network, peerId: PeerId,
let users = users.filter({ user in
return participants.contains(where: { participant in
switch participant {
case let .channelParticipantAdmin(_, userId, _, _, _, _):
case let .channelParticipantAdmin(_, userId, _, _, _, _, _):
return user.peerId.id == userId
case let .channelParticipantCreator(userId):
case let .channelParticipantCreator(_, userId, _):
return user.peerId.id == userId
default:
return false

View File

@@ -224,7 +224,7 @@ public func updateChannelAdminRights(account: Account, peerId: PeerId, adminId:
}
updatedParticipant = ChannelParticipant.member(id: adminId, invitedAt: Int32(Date().timeIntervalSince1970), adminInfo: adminInfo, banInfo: nil)
}
return account.network.request(Api.functions.channels.editAdmin(channel: inputChannel, userId: inputUser, adminRights: rights.apiAdminRights))
return account.network.request(Api.functions.channels.editAdmin(channel: inputChannel, userId: inputUser, adminRights: rights.apiAdminRights, rank: ""))
|> map { [$0] }
|> `catch` { error -> Signal<[Api.Updates], UpdateChannelAdminRightsError> in
if error.errorDescription == "USER_NOT_PARTICIPANT" {
@@ -235,7 +235,7 @@ public func updateChannelAdminRights(account: Account, peerId: PeerId, adminId:
|> mapError { error -> UpdateChannelAdminRightsError in
return .addMemberError(error)
}
|> then(account.network.request(Api.functions.channels.editAdmin(channel: inputChannel, userId: inputUser, adminRights: rights.apiAdminRights))
|> then(account.network.request(Api.functions.channels.editAdmin(channel: inputChannel, userId: inputUser, adminRights: rights.apiAdminRights, rank: ""))
|> mapError { error -> UpdateChannelAdminRightsError in
return .generic
}

View File

@@ -38,7 +38,7 @@ public func secureIdPreparePhoneVerification(network: Network, value: SecureIdPh
}
|> map { sentCode -> SecureIdPreparePhoneVerificationPayload in
switch sentCode {
case let .sentCode(_, type, phoneCodeHash, nextType, timeout, _):
case let .sentCode(_, type, phoneCodeHash, nextType, timeout):
return SecureIdPreparePhoneVerificationPayload(type: SentAuthorizationCodeType(apiType: type), nextType: nextType.flatMap(AuthorizationCodeNextType.init), timeout: timeout, phone: value.phone, phoneCodeHash: phoneCodeHash)
}
}

View File

@@ -721,13 +721,13 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
}
controllers.append(self.phoneEntryController(countryCode: countryCode, number: number))
self.setViewControllers(controllers, animated: !self.viewControllers.isEmpty)
case let .confirmationCodeEntry(number, type, _, timeout, nextType, termsOfService, syncContacts):
case let .confirmationCodeEntry(number, type, _, timeout, nextType, _):
var controllers: [ViewController] = []
if !self.otherAccountPhoneNumbers.1.isEmpty {
controllers.append(self.splashController())
}
controllers.append(self.phoneEntryController(countryCode: defaultCountryCode(), number: ""))
controllers.append(self.codeEntryController(number: number, type: type, nextType: nextType, timeout: timeout, termsOfService: termsOfService))
controllers.append(self.codeEntryController(number: number, type: type, nextType: nextType, timeout: timeout, termsOfService: nil))
self.setViewControllers(controllers, animated: !self.viewControllers.isEmpty)
case let .passwordEntry(hint, _, _, suggestReset, syncContacts):
var controllers: [ViewController] = []