mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 03:40:18 +00:00
Fixed error 406 handling on supergroup creation
This commit is contained in:
parent
855e98f9c5
commit
f0bd7aeffd
@ -19,6 +19,7 @@ public enum CreateChannelError {
|
|||||||
case generic
|
case generic
|
||||||
case restricted
|
case restricted
|
||||||
case tooMuchLocationBasedGroups
|
case tooMuchLocationBasedGroups
|
||||||
|
case serverProvided(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createChannel(account: Account, title: String, description: String?, isSupergroup:Bool, location: (latitude: Double, longitude: Double, address: String)? = nil) -> Signal<PeerId, CreateChannelError> {
|
private func createChannel(account: Account, title: String, description: String?, isSupergroup:Bool, location: (latitude: Double, longitude: Double, address: String)? = nil) -> Signal<PeerId, CreateChannelError> {
|
||||||
@ -40,7 +41,9 @@ private func createChannel(account: Account, title: String, description: String?
|
|||||||
|
|
||||||
return account.network.request(Api.functions.channels.createChannel(flags: flags, title: title, about: description ?? "", geoPoint: geoPoint, address: address), automaticFloodWait: false)
|
return account.network.request(Api.functions.channels.createChannel(flags: flags, title: title, about: description ?? "", geoPoint: geoPoint, address: address), automaticFloodWait: false)
|
||||||
|> mapError { error -> CreateChannelError in
|
|> mapError { error -> CreateChannelError in
|
||||||
if error.errorDescription == "CHANNELS_ADMIN_LOCATED_TOO_MUCH" {
|
if error.errorCode == 406 {
|
||||||
|
return .serverProvided(error.errorDescription)
|
||||||
|
} else if error.errorDescription == "CHANNELS_ADMIN_LOCATED_TOO_MUCH" {
|
||||||
return .tooMuchLocationBasedGroups
|
return .tooMuchLocationBasedGroups
|
||||||
} else if error.errorDescription == "USER_RESTRICTED" {
|
} else if error.errorDescription == "USER_RESTRICTED" {
|
||||||
return .restricted
|
return .restricted
|
||||||
|
|||||||
@ -20,6 +20,7 @@ public enum CreateGroupError {
|
|||||||
case privacy
|
case privacy
|
||||||
case restricted
|
case restricted
|
||||||
case tooMuchLocationBasedGroups
|
case tooMuchLocationBasedGroups
|
||||||
|
case serverProvided(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func createGroup(account: Account, title: String, peerIds: [PeerId]) -> Signal<PeerId?, CreateGroupError> {
|
public func createGroup(account: Account, title: String, peerIds: [PeerId]) -> Signal<PeerId?, CreateGroupError> {
|
||||||
|
|||||||
@ -258,14 +258,18 @@ public func createChannelController(context: AccountContext) -> ViewController {
|
|||||||
replaceControllerImpl?(controller)
|
replaceControllerImpl?(controller)
|
||||||
}, error: { error in
|
}, error: { error in
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
let text: String
|
let text: String?
|
||||||
switch error {
|
switch error {
|
||||||
case .generic, .tooMuchLocationBasedGroups:
|
case .generic, .tooMuchLocationBasedGroups:
|
||||||
text = presentationData.strings.Login_UnknownError
|
text = presentationData.strings.Login_UnknownError
|
||||||
case .restricted:
|
case .restricted:
|
||||||
text = presentationData.strings.Common_ActionNotAllowedError
|
text = presentationData.strings.Common_ActionNotAllowedError
|
||||||
|
default:
|
||||||
|
text = nil
|
||||||
|
}
|
||||||
|
if let text = text {
|
||||||
|
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||||
}
|
}
|
||||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}, changeProfilePhoto: {
|
}, changeProfilePhoto: {
|
||||||
|
|||||||
@ -358,6 +358,8 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId], in
|
|||||||
return .restricted
|
return .restricted
|
||||||
case .tooMuchLocationBasedGroups:
|
case .tooMuchLocationBasedGroups:
|
||||||
return .tooMuchLocationBasedGroups
|
return .tooMuchLocationBasedGroups
|
||||||
|
case let .serverProvided(error):
|
||||||
|
return .serverProvided(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .locatedGroup:
|
case .locatedGroup:
|
||||||
@ -381,6 +383,8 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId], in
|
|||||||
return .restricted
|
return .restricted
|
||||||
case .tooMuchLocationBasedGroups:
|
case .tooMuchLocationBasedGroups:
|
||||||
return .tooMuchLocationBasedGroups
|
return .tooMuchLocationBasedGroups
|
||||||
|
case let .serverProvided(error):
|
||||||
|
return .serverProvided(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,8 +435,12 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId], in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, error: { error in
|
}, error: { error in
|
||||||
|
if case .serverProvided = error {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
let text: String
|
let text: String?
|
||||||
switch error {
|
switch error {
|
||||||
case .privacy:
|
case .privacy:
|
||||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelMultipleError
|
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelMultipleError
|
||||||
@ -442,8 +450,13 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId], in
|
|||||||
text = presentationData.strings.Common_ActionNotAllowedError
|
text = presentationData.strings.Common_ActionNotAllowedError
|
||||||
case .tooMuchLocationBasedGroups:
|
case .tooMuchLocationBasedGroups:
|
||||||
text = presentationData.strings.CreateGroup_ErrorLocatedGroupsTooMuch
|
text = presentationData.strings.CreateGroup_ErrorLocatedGroupsTooMuch
|
||||||
|
default:
|
||||||
|
text = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if let text = text {
|
||||||
|
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||||
}
|
}
|
||||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}, changeProfilePhoto: {
|
}, changeProfilePhoto: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user