Don't warn about sent message ID decrease after message ID overflow.

This commit is contained in:
levlam 2021-08-02 07:09:40 +03:00
parent aba7118679
commit 9e7bce1b06
2 changed files with 21 additions and 4 deletions

View File

@ -13632,7 +13632,8 @@ FullMessageId MessagesManager::on_get_message(MessageInfo &&message_info, bool f
need_update = false;
if (old_message_id.is_valid() && message_id.is_valid() && message_id < old_message_id) {
if (old_message_id.is_valid() && message_id.is_valid() && message_id < old_message_id &&
!can_overflow_message_id(dialog_id)) {
LOG(ERROR) << "Sent " << old_message_id << " to " << dialog_id << " as " << message_id;
}
@ -23104,8 +23105,7 @@ void MessagesManager::fix_server_reply_to_message_id(DialogId dialog_id, Message
}
if (!message_id.is_scheduled() && !reply_in_dialog_id.is_valid() && reply_to_message_id >= message_id) {
if (reply_to_message_id.get() - message_id.get() <= MessageId(ServerMessageId(1000000)).get() ||
dialog_id.get_type() == DialogType::Channel) {
if (!can_overflow_message_id(dialog_id)) {
LOG(ERROR) << "Receive reply to wrong " << reply_to_message_id << " in " << message_id << " in " << dialog_id;
}
reply_to_message_id = MessageId();
@ -24448,6 +24448,21 @@ void MessagesManager::do_send_inline_query_result_message(DialogId dialog_id, co
flags, dialog_id, m->reply_to_message_id, get_message_schedule_date(m), random_id, query_id, result_id);
}
bool MessagesManager::can_overflow_message_id(DialogId dialog_id) {
switch (dialog_id.get_type()) {
case DialogType::User:
case DialogType::Chat:
return G()->shared_config().get_option_integer("session_count") > 1;
case DialogType::Channel:
case DialogType::SecretChat:
return false;
case DialogType::None:
default:
UNREACHABLE();
return false;
}
}
bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, bool is_editing,
bool only_reply_markup) const {
if (m == nullptr) {
@ -28612,7 +28627,7 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
send_update_message_content(dialog_id, sent_message.get(), source);
}
if (old_message_id.is_valid() && new_message_id < old_message_id) {
if (old_message_id.is_valid() && new_message_id < old_message_id && !can_overflow_message_id(dialog_id)) {
LOG(ERROR) << "Sent " << old_message_id << " to " << dialog_id << " as " << new_message_id;
}

View File

@ -1767,6 +1767,8 @@ class MessagesManager final : public Actor {
bool can_edit_message(DialogId dialog_id, const Message *m, bool is_editing, bool only_reply_markup = false) const;
static bool can_overflow_message_id(DialogId dialog_id);
bool can_report_dialog(DialogId dialog_id) const;
Status can_pin_messages(DialogId dialog_id) const;