mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-03 03:10:47 +00:00
Added CHANNELS_TOO_MUCH error support all across the app
This commit is contained in:
parent
684a933fa3
commit
13a3a16c91
@ -4460,3 +4460,7 @@ Any member of this group will be able to see messages in the channel.";
|
||||
"Activity.RemindAboutGroup" = "Send message to %@";
|
||||
"Activity.RemindAboutUser" = "Send message to %@";
|
||||
"Activity.RemindAboutChannel" = "Read %@";
|
||||
|
||||
"CreateGroup.ChannelsTooMuch" = "Sorry, you are a member of too many groups and channels. Please leave some before creating a new one.";
|
||||
"Join.ChannelsTooMuch" = "Sorry, you are a member of too many groups and channels. Please leave some before joining one.";
|
||||
"Invite.ChannelsTooMuch" = "Sorry, the target user is a member of too many groups and channels. Please ask them to leave some first.";
|
||||
|
@ -75,6 +75,7 @@ public enum AddChannelMemberError {
|
||||
case generic
|
||||
case restricted
|
||||
case limitExceeded
|
||||
case tooMuchJoined
|
||||
case bot(PeerId)
|
||||
}
|
||||
|
||||
@ -97,6 +98,8 @@ public func addChannelMember(account: Account, peerId: PeerId, memberId: PeerId)
|
||||
|> map { [$0] }
|
||||
|> `catch` { error -> Signal<[Api.Updates], AddChannelMemberError> in
|
||||
switch error.errorDescription {
|
||||
case "CHANNELS_TOO_MUCH":
|
||||
return .fail(.tooMuchJoined)
|
||||
case "USERS_TOO_MUCH":
|
||||
return .fail(.limitExceeded)
|
||||
case "USER_PRIVACY_RESTRICTED":
|
||||
@ -190,6 +193,8 @@ public func addChannelMembers(account: Account, peerId: PeerId, memberIds: [Peer
|
||||
let signal = account.network.request(Api.functions.channels.inviteToChannel(channel: inputChannel, users: inputUsers))
|
||||
|> mapError { error -> AddChannelMemberError in
|
||||
switch error.errorDescription {
|
||||
case "CHANNELS_TOO_MUCH":
|
||||
return .tooMuchJoined
|
||||
case "USER_PRIVACY_RESTRICTED":
|
||||
return .restricted
|
||||
case "USERS_TOO_MUCH":
|
||||
|
@ -18,6 +18,7 @@ import Foundation
|
||||
public enum CreateChannelError {
|
||||
case generic
|
||||
case restricted
|
||||
case tooMuchJoined
|
||||
case tooMuchLocationBasedGroups
|
||||
case serverProvided(String)
|
||||
}
|
||||
@ -43,6 +44,8 @@ private func createChannel(account: Account, title: String, description: String?
|
||||
|> mapError { error -> CreateChannelError in
|
||||
if error.errorCode == 406 {
|
||||
return .serverProvided(error.errorDescription)
|
||||
} else if error.errorDescription == "CHANNELS_TOO_MUCH" {
|
||||
return .tooMuchJoined
|
||||
} else if error.errorDescription == "CHANNELS_ADMIN_LOCATED_TOO_MUCH" {
|
||||
return .tooMuchLocationBasedGroups
|
||||
} else if error.errorDescription == "USER_RESTRICTED" {
|
||||
|
@ -19,6 +19,7 @@ public enum CreateGroupError {
|
||||
case generic
|
||||
case privacy
|
||||
case restricted
|
||||
case tooMuchJoined
|
||||
case tooMuchLocationBasedGroups
|
||||
case serverProvided(String)
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import Foundation
|
||||
|
||||
public enum JoinChannelError {
|
||||
case generic
|
||||
case tooMuchJoined
|
||||
}
|
||||
|
||||
public func joinChannel(account: Account, peerId: PeerId) -> Signal<RenderedChannelParticipant?, JoinChannelError> {
|
||||
@ -20,8 +21,12 @@ public func joinChannel(account: Account, peerId: PeerId) -> Signal<RenderedChan
|
||||
|> mapToSignal { peer -> Signal<RenderedChannelParticipant?, JoinChannelError> in
|
||||
if let inputChannel = apiInputChannel(peer) {
|
||||
return account.network.request(Api.functions.channels.joinChannel(channel: inputChannel))
|
||||
|> mapError { _ -> JoinChannelError in
|
||||
return .generic
|
||||
|> mapError { error -> JoinChannelError in
|
||||
if error.errorDescription == "CHANNELS_TOO_MUCH" {
|
||||
return .tooMuchJoined
|
||||
} else {
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<RenderedChannelParticipant?, JoinChannelError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -376,6 +376,8 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) ->
|
||||
switch error {
|
||||
case .limitExceeded:
|
||||
text = presentationData.strings.Channel_ErrorAddTooMuch
|
||||
case .tooMuchJoined:
|
||||
text = presentationData.strings.Invite_ChannelsTooMuch
|
||||
case .generic:
|
||||
text = presentationData.strings.Login_UnknownError
|
||||
case .restricted:
|
||||
|
@ -126,15 +126,20 @@ final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
|
||||
strongSelf.activityIndicator.stopAnimating()
|
||||
}
|
||||
}
|
||||
}).start(error: { [weak self] _ in
|
||||
}).start(error: { [weak self] error in
|
||||
guard let strongSelf = self, let presentationInterfaceState = strongSelf.presentationInterfaceState, let peer = presentationInterfaceState.renderedPeer?.peer else {
|
||||
return
|
||||
}
|
||||
let text: String
|
||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||
text = presentationInterfaceState.strings.Channel_ErrorAccessDenied
|
||||
} else {
|
||||
text = presentationInterfaceState.strings.Group_ErrorAccessDenied
|
||||
switch error {
|
||||
case .tooMuchJoined:
|
||||
text = presentationInterfaceState.strings.Join_ChannelsTooMuch
|
||||
default:
|
||||
if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||
text = presentationInterfaceState.strings.Channel_ErrorAccessDenied
|
||||
} else {
|
||||
text = presentationInterfaceState.strings.Group_ErrorAccessDenied
|
||||
}
|
||||
}
|
||||
strongSelf.interfaceInteraction?.presentController(textAlertController(context: context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationInterfaceState.strings.Common_OK, action: {})]), nil)
|
||||
}))
|
||||
|
@ -262,6 +262,8 @@ public func createChannelController(context: AccountContext) -> ViewController {
|
||||
switch error {
|
||||
case .generic, .tooMuchLocationBasedGroups:
|
||||
text = presentationData.strings.Login_UnknownError
|
||||
case .tooMuchJoined:
|
||||
text = presentationData.strings.CreateGroup_ChannelsTooMuch
|
||||
case .restricted:
|
||||
text = presentationData.strings.Common_ActionNotAllowedError
|
||||
default:
|
||||
|
@ -356,6 +356,8 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId], in
|
||||
return .generic
|
||||
case .restricted:
|
||||
return .restricted
|
||||
case .tooMuchJoined:
|
||||
return .tooMuchJoined
|
||||
case .tooMuchLocationBasedGroups:
|
||||
return .tooMuchLocationBasedGroups
|
||||
case let .serverProvided(error):
|
||||
@ -381,6 +383,8 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId], in
|
||||
return .generic
|
||||
case .restricted:
|
||||
return .restricted
|
||||
case .tooMuchJoined:
|
||||
return .tooMuchJoined
|
||||
case .tooMuchLocationBasedGroups:
|
||||
return .tooMuchLocationBasedGroups
|
||||
case let .serverProvided(error):
|
||||
@ -448,6 +452,8 @@ public func createGroupController(context: AccountContext, peerIds: [PeerId], in
|
||||
text = presentationData.strings.Login_UnknownError
|
||||
case .restricted:
|
||||
text = presentationData.strings.Common_ActionNotAllowedError
|
||||
case .tooMuchJoined:
|
||||
text = presentationData.strings.CreateGroup_ChannelsTooMuch
|
||||
case .tooMuchLocationBasedGroups:
|
||||
text = presentationData.strings.CreateGroup_ErrorLocatedGroupsTooMuch
|
||||
default:
|
||||
|
@ -1815,13 +1815,13 @@ public func groupInfoController(context: AccountContext, peerId originalPeerId:
|
||||
|> deliverOnMainQueue).start(error: { error in
|
||||
if peers.count == 1, case .restricted = error {
|
||||
switch peers[0] {
|
||||
case let .peer(peerId):
|
||||
let _ = (context.account.postbox.loadedPeerWithId(peerId)
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(peer.compactDisplayTitle, peer.compactDisplayTitle).0, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
})
|
||||
default:
|
||||
break
|
||||
case let .peer(peerId):
|
||||
let _ = (context.account.postbox.loadedPeerWithId(peerId)
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(peer.compactDisplayTitle, peer.compactDisplayTitle).0, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
})
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,23 +327,6 @@ final class PeerChannelMemberCategoriesContextsManager {
|
||||
|> mapToSignal { _ -> Signal<Void, AddChannelMemberError> in
|
||||
return .complete()
|
||||
}
|
||||
|
||||
/*return addChannelMembers(account: account, peerId: peerId, memberIds: memberIds)
|
||||
|> deliverOnMainQueue
|
||||
|> beforeNext { [weak self] result in
|
||||
if let strongSelf = self {
|
||||
strongSelf.impl.with { impl in
|
||||
for (contextPeerId, context) in impl.contexts {
|
||||
if peerId == contextPeerId {
|
||||
context.reset(.recent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|> mapToSignal { _ -> Signal<Void, AddChannelMemberError> in
|
||||
return .single(Void())
|
||||
}*/
|
||||
}
|
||||
|
||||
func recentOnline(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId) -> Signal<Int32, NoError> {
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user