Fix replacing of unacceptable update with updateChannelTooLong.

GitOrigin-RevId: a82f6e6e9e828183aa10690ebe32b983f7433ed4
This commit is contained in:
levlam 2018-04-04 23:03:35 +03:00
parent 46552ce43f
commit 72515a4459

View File

@ -1126,13 +1126,18 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
message_ptr = &update_edit_channel_message->message_; message_ptr = &update_edit_channel_message->message_;
pts = update_edit_channel_message->pts_; pts = update_edit_channel_message->pts_;
} }
if (message_ptr != nullptr) {
// 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) {
auto dialog_id = td_->messages_manager_->get_message_dialog_id(*message_ptr); auto dialog_id = td_->messages_manager_->get_message_dialog_id(*message_ptr);
if (dialog_id.get_type() == DialogType::Channel) { if (dialog_id.get_type() == DialogType::Channel) {
// for channels we can replace unacceptable update with updateChannelTooLong auto channel_id = dialog_id.get_channel_id();
if (td_->contacts_manager_->have_channel_force(channel_id)) {
update = telegram_api::make_object<telegram_api::updateChannelTooLong>( update = telegram_api::make_object<telegram_api::updateChannelTooLong>(
telegram_api::updateChannelTooLong::PTS_MASK, dialog_id.get_channel_id().get(), pts); telegram_api::updateChannelTooLong::PTS_MASK, channel_id.get(), pts);
continue; continue;
}
} else { } else {
LOG(ERROR) << "Update is not from a channel: " << to_string(update); LOG(ERROR) << "Update is not from a channel: " << to_string(update);
} }