mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Add chat flood error
This commit is contained in:
parent
f92f4c38c6
commit
16d5058cc7
@ -9081,3 +9081,6 @@ Sorry for the inconvenience.";
|
|||||||
|
|
||||||
"CreateGroup.PeersTitleDelimeter" = ", ";
|
"CreateGroup.PeersTitleDelimeter" = ", ";
|
||||||
"CreateGroup.PeersTitleLastDelimeter" = " and ";
|
"CreateGroup.PeersTitleLastDelimeter" = " and ";
|
||||||
|
|
||||||
|
"Conversation.SendMessageErrorTooFastTitle" = "Not so fast";
|
||||||
|
"Conversation.SendMessageErrorTooFast" = "You are sending messages too fast. Please wait a bit.";
|
||||||
|
@ -57,11 +57,14 @@ public enum PendingMessageFailureReason {
|
|||||||
case slowmodeActive
|
case slowmodeActive
|
||||||
case tooMuchScheduled
|
case tooMuchScheduled
|
||||||
case voiceMessagesForbidden
|
case voiceMessagesForbidden
|
||||||
|
case sendingTooFast
|
||||||
}
|
}
|
||||||
|
|
||||||
private func reasonForError(_ error: String) -> PendingMessageFailureReason? {
|
private func reasonForError(_ error: String) -> PendingMessageFailureReason? {
|
||||||
if error.hasPrefix("PEER_FLOOD") {
|
if error.hasPrefix("PEER_FLOOD") {
|
||||||
return .flood
|
return .flood
|
||||||
|
} else if error.hasPrefix("SENDING_TOO_FAST") {
|
||||||
|
return .sendingTooFast
|
||||||
} else if error.hasPrefix("USER_BANNED_IN_CHANNEL") {
|
} else if error.hasPrefix("USER_BANNED_IN_CHANNEL") {
|
||||||
return .publicBan
|
return .publicBan
|
||||||
} else if error.hasPrefix("CHAT_SEND_") && error.hasSuffix("_FORBIDDEN") {
|
} else if error.hasPrefix("CHAT_SEND_") && error.hasSuffix("_FORBIDDEN") {
|
||||||
|
@ -10555,11 +10555,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|> deliverOnMainQueue).start(next: { [weak self] reason in
|
|> deliverOnMainQueue).start(next: { [weak self] reason in
|
||||||
if let strongSelf = self, strongSelf.currentFailedMessagesAlertController == nil {
|
if let strongSelf = self, strongSelf.currentFailedMessagesAlertController == nil {
|
||||||
let text: String
|
let text: String
|
||||||
|
var title: String?
|
||||||
let moreInfo: Bool
|
let moreInfo: Bool
|
||||||
switch reason {
|
switch reason {
|
||||||
case .flood:
|
case .flood:
|
||||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorFlood
|
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorFlood
|
||||||
moreInfo = true
|
moreInfo = true
|
||||||
|
case .sendingTooFast:
|
||||||
|
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFast
|
||||||
|
title = strongSelf.presentationData.strings.Conversation_SendMessageErrorTooFastTitle
|
||||||
|
moreInfo = false
|
||||||
case .publicBan:
|
case .publicBan:
|
||||||
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorGroupRestricted
|
text = strongSelf.presentationData.strings.Conversation_SendMessageErrorGroupRestricted
|
||||||
moreInfo = true
|
moreInfo = true
|
||||||
@ -10584,7 +10589,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
} else {
|
} else {
|
||||||
actions = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]
|
actions = [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]
|
||||||
}
|
}
|
||||||
let controller = textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: nil, text: text, actions: actions)
|
let controller = textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: title, text: text, actions: actions)
|
||||||
strongSelf.currentFailedMessagesAlertController = controller
|
strongSelf.currentFailedMessagesAlertController = controller
|
||||||
strongSelf.present(controller, in: .window(.root))
|
strongSelf.present(controller, in: .window(.root))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user