Allow outdated unacceptable updates to avoid getDifference after trying to apply every such pending update.
GitOrigin-RevId: 61944ec2b4e81fa2ca61bee5887220964e0c9cbc
This commit is contained in:
parent
47a0ee9520
commit
660acfef22
@ -6127,7 +6127,7 @@ void MessagesManager::cancel_user_dialog_action(DialogId dialog_id, const Messag
|
||||
|
||||
void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_ptr<telegram_api::Update> &&update,
|
||||
int32 new_pts, int32 pts_count, const char *source,
|
||||
bool is_postponed_udpate) {
|
||||
bool is_postponed_update) {
|
||||
LOG(INFO) << "Receive from " << source << " pending " << to_string(update);
|
||||
CHECK(update != nullptr);
|
||||
CHECK(dialog_id.get_type() == DialogType::Channel);
|
||||
@ -6166,7 +6166,7 @@ void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_p
|
||||
} else {
|
||||
int32 old_pts = d->pts;
|
||||
if (new_pts <= old_pts) { // very old or unuseful update
|
||||
if (new_pts < old_pts - 19999 && !is_postponed_udpate) {
|
||||
if (new_pts < old_pts - 19999 && !is_postponed_update) {
|
||||
// restore channel pts after delete_first_messages
|
||||
LOG(ERROR) << "Restore pts in " << d->dialog_id << " from " << source << " after delete_first_messages from "
|
||||
<< old_pts << " to " << new_pts << " is temporarily disabled, pts_count = " << pts_count
|
||||
@ -6245,6 +6245,13 @@ void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_p
|
||||
set_channel_pts(d, new_pts, source);
|
||||
}
|
||||
|
||||
bool MessagesManager::is_old_channel_update(DialogId dialog_id, int32 new_pts) {
|
||||
CHECK(dialog_id.get_type() == DialogType::Channel);
|
||||
|
||||
const Dialog *d = get_dialog_force(dialog_id);
|
||||
return new_pts <= (d == nullptr ? load_channel_pts(dialog_id) : d->pts);
|
||||
}
|
||||
|
||||
void MessagesManager::set_get_difference_timeout(double timeout) {
|
||||
if (!pts_gap_timeout_.has_timeout()) {
|
||||
LOG(INFO) << "Gap in pts has found, current pts is " << td_->updates_manager_->get_pts();
|
||||
|
@ -663,6 +663,8 @@ class MessagesManager : public Actor {
|
||||
void add_pending_channel_update(DialogId dialog_id, tl_object_ptr<telegram_api::Update> &&update, int32 new_pts,
|
||||
int32 pts_count, const char *source, bool is_postponed_update = false);
|
||||
|
||||
bool is_old_channel_update(DialogId dialog_id, int32 new_pts);
|
||||
|
||||
bool is_update_about_username_change_received(DialogId dialog_id) const;
|
||||
|
||||
void on_dialog_bots_updated(DialogId dialog_id, vector<UserId> bot_user_ids);
|
||||
|
@ -1173,17 +1173,24 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
|
||||
}
|
||||
|
||||
// for channels we can try to replace unacceptable update with updateChannelTooLong
|
||||
// don't do that for service messages, because they can be about bot's kicking
|
||||
if (message_ptr != nullptr && (*message_ptr)->get_id() != telegram_api::messageService::ID) {
|
||||
if (message_ptr != nullptr) {
|
||||
auto dialog_id = td_->messages_manager_->get_message_dialog_id(*message_ptr);
|
||||
if (dialog_id.get_type() == DialogType::Channel) {
|
||||
LOG(INFO) << "Replace update about new message with updateChannelTooLong in " << dialog_id;
|
||||
auto channel_id = dialog_id.get_channel_id();
|
||||
if (td_->contacts_manager_->have_channel_force(channel_id)) {
|
||||
if (td_->messages_manager_->is_old_channel_update(dialog_id, pts)) {
|
||||
// the update will be ignored anyway, so there is no reason to replace it or force get_difference
|
||||
LOG(INFO) << "Allow an outdated unacceptable update from " << source;
|
||||
continue;
|
||||
}
|
||||
if ((*message_ptr)->get_id() != telegram_api::messageService::ID) {
|
||||
// don't replace service messages, because they can be about bot's kicking
|
||||
LOG(INFO) << "Replace update about new message with updateChannelTooLong in " << dialog_id;
|
||||
update = telegram_api::make_object<telegram_api::updateChannelTooLong>(
|
||||
telegram_api::updateChannelTooLong::PTS_MASK, channel_id.get(), pts);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG(ERROR) << "Update is not from a channel: " << to_string(update);
|
||||
}
|
||||
|
Reference in New Issue
Block a user