Use error object in td_api::messageSendingStateFailed/updateMessageSendFailed.

This commit is contained in:
levlam 2023-09-19 19:04:56 +03:00
parent a19d49a107
commit 6b17c0fdec
3 changed files with 20 additions and 20 deletions

View File

@ -1147,12 +1147,11 @@ unreadReaction type:ReactionType sender_id:MessageSender is_big:Bool = UnreadRea
messageSendingStatePending sending_id:int32 = MessageSendingState;
//@description The message failed to be sent
//@error_code An error code; 0 if unknown
//@error_message Error message
//@error The cause of the message sending failure
//@can_retry True, if the message can be re-sent
//@need_another_sender True, if the message can be re-sent only on behalf of a different sender
//@retry_after Time left before the message can be re-sent, in seconds. No update is sent when this field changes
messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool need_another_sender:Bool retry_after:double = MessageSendingState;
messageSendingStateFailed error:error can_retry:Bool need_another_sender:Bool retry_after:double = MessageSendingState;
//@class MessageReplyTo @description Contains information about the message or the story a message is replying to
@ -5751,9 +5750,8 @@ updateMessageSendSucceeded message:message old_message_id:int53 = Update;
//@description A message failed to send. Be aware that some messages being sent can be irrecoverably deleted, in which case updateDeleteMessages will be received instead of this update
//@message The failed to send message
//@old_message_id The previous temporary message identifier
//@error_code An error code
//@error_message Error message
updateMessageSendFailed message:message old_message_id:int53 error_code:int32 error_message:string = Update;
//@error The cause of the message sending failure
updateMessageSendFailed message:message old_message_id:int53 error:error = Update;
//@description The message content has changed @chat_id Chat identifier @message_id Message identifier @new_content New message content
updateMessageContent chat_id:int53 message_id:int53 new_content:MessageContent = Update;
@ -6035,7 +6033,7 @@ updateStorySendSucceeded story:story old_story_id:int32 = Update;
//@description A story failed to send. If the story sending is canceled, then updateStoryDeleted will be received instead of this update
//@story The failed to send story
//@error The cause of the failure; may be null if unknown
//@error The cause of the story sending failure; may be null if unknown
//@error_code An error code
//@error_message Error message
updateStorySendFailed story:story error:CanSendStoryResult error_code:int32 error_message:string = Update;

View File

@ -24094,11 +24094,12 @@ tl_object_ptr<td_api::MessageSendingState> MessagesManager::get_message_sending_
}
if (m->is_failed_to_send) {
auto can_retry = can_resend_message(m);
auto error_code = m->send_error_code > 0 ? m->send_error_code : 400;
auto need_another_sender =
can_retry && m->send_error_code == 400 && m->send_error_message == CSlice("SEND_AS_PEER_INVALID");
return td_api::make_object<td_api::messageSendingStateFailed>(m->send_error_code, m->send_error_message, can_retry,
need_another_sender,
max(m->try_resend_at - Time::now(), 0.0));
can_retry && error_code == 400 && m->send_error_message == CSlice("SEND_AS_PEER_INVALID");
return td_api::make_object<td_api::messageSendingStateFailed>(
td_api::make_object<td_api::error>(error_code, m->send_error_message), can_retry, need_another_sender,
max(m->try_resend_at - Time::now(), 0.0));
}
return nullptr;
}
@ -31299,9 +31300,6 @@ void MessagesManager::on_send_message_fail(int64 random_id, Status error) {
if (error_code != 403 && !(error_code == 500 && G()->close_flag())) {
LOG(WARNING) << "Failed to send " << full_message_id << " with the error " << error;
}
if (error_code <= 0) {
error_code = 500;
}
fail_send_message(full_message_id, error_code, error_message);
}
@ -31363,7 +31361,11 @@ MessageId MessagesManager::get_next_yet_unsent_scheduled_message_id(Dialog *d, i
return last_assigned_message_id;
}
void MessagesManager::fail_send_message(FullMessageId full_message_id, int error_code, const string &error_message) {
void MessagesManager::fail_send_message(FullMessageId full_message_id, int32 error_code, const string &error_message) {
if (error_code <= 0) {
error_code = 500;
}
auto dialog_id = full_message_id.get_dialog_id();
Dialog *d = get_dialog(dialog_id);
CHECK(d != nullptr);
@ -31434,10 +31436,10 @@ void MessagesManager::fail_send_message(FullMessageId full_message_id, int error
if (!td_->auth_manager_->is_bot()) {
yet_unsent_full_message_id_to_persistent_message_id_.emplace({dialog_id, old_message_id}, m->message_id);
}
send_closure(
G()->td(), &Td::send_update,
td_api::make_object<td_api::updateMessageSendFailed>(get_message_object(dialog_id, m, "fail_send_message"),
old_message_id.get(), error_code, error_message));
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateMessageSendFailed>(
get_message_object(dialog_id, m, "fail_send_message"), old_message_id.get(),
td_api::make_object<td_api::error>(error_code, error_message)));
if (need_update_dialog_pos) {
send_update_chat_last_message(d, "fail_send_message");
}

View File

@ -2255,7 +2255,7 @@ class MessagesManager final : public Actor {
bool is_message_auto_read(DialogId dialog_id, bool is_outgoing) const;
void fail_send_message(FullMessageId full_message_id, int error_code, const string &error_message);
void fail_send_message(FullMessageId full_message_id, int32 error_code, const string &error_message);
void fail_send_message(FullMessageId full_message_id, Status error);