Support some updates before authorization.
GitOrigin-RevId: 21bd7a06bf41ebc81005b35a0695988d82e6b4a3
This commit is contained in:
parent
12a6bc9c04
commit
a599557c9d
@ -3675,6 +3675,11 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
|||||||
tl_object_ptr<telegram_api::MessageMedia> &&media,
|
tl_object_ptr<telegram_api::MessageMedia> &&media,
|
||||||
DialogId owner_dialog_id, bool is_content_read, UserId via_bot_user_id,
|
DialogId owner_dialog_id, bool is_content_read, UserId via_bot_user_id,
|
||||||
int32 *ttl) {
|
int32 *ttl) {
|
||||||
|
if (!td->auth_manager_->is_authorized() && !G()->close_flag() && media != nullptr) {
|
||||||
|
LOG(ERROR) << "Receive without authorization " << to_string(media);
|
||||||
|
media = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
int32 constructor_id = media == nullptr ? telegram_api::messageMediaEmpty::ID : media->get_id();
|
int32 constructor_id = media == nullptr ? telegram_api::messageMediaEmpty::ID : media->get_id();
|
||||||
switch (constructor_id) {
|
switch (constructor_id) {
|
||||||
case telegram_api::messageMediaEmpty::ID:
|
case telegram_api::messageMediaEmpty::ID:
|
||||||
|
@ -5468,12 +5468,14 @@ void MessagesManager::on_update_service_notification(tl_object_ptr<telegram_api:
|
|||||||
old_date = date;
|
old_date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto message_text =
|
bool is_authorized = td_->auth_manager_->is_authorized();
|
||||||
get_message_text(td_->contacts_manager_.get(), std::move(update->message_), std::move(update->entities_),
|
bool is_user = is_authorized && !td_->auth_manager_->is_bot();
|
||||||
|
auto contacts_manager = is_authorized ? td_->contacts_manager_.get() : nullptr;
|
||||||
|
auto message_text = get_message_text(contacts_manager, std::move(update->message_), std::move(update->entities_),
|
||||||
skip_new_entities, date, false, "on_update_service_notification");
|
skip_new_entities, date, false, "on_update_service_notification");
|
||||||
auto content = get_message_content(
|
DialogId owner_dialog_id = is_user ? get_service_notifications_dialog()->dialog_id : DialogId();
|
||||||
td_, std::move(message_text), std::move(update->media_),
|
auto content = get_message_content(td_, std::move(message_text), std::move(update->media_), owner_dialog_id, false,
|
||||||
td_->auth_manager_->is_bot() ? DialogId() : get_service_notifications_dialog()->dialog_id, false, UserId(), &ttl);
|
UserId(), &ttl);
|
||||||
bool is_content_secret = is_secret_message_content(ttl, content->get_type());
|
bool is_content_secret = is_secret_message_content(ttl, content->get_type());
|
||||||
|
|
||||||
if ((update->flags_ & telegram_api::updateServiceNotification::POPUP_MASK) != 0) {
|
if ((update->flags_ & telegram_api::updateServiceNotification::POPUP_MASK) != 0) {
|
||||||
@ -5481,7 +5483,7 @@ void MessagesManager::on_update_service_notification(tl_object_ptr<telegram_api:
|
|||||||
td_api::make_object<td_api::updateServiceNotification>(
|
td_api::make_object<td_api::updateServiceNotification>(
|
||||||
update->type_, get_message_content_object(content.get(), td_, date, is_content_secret)));
|
update->type_, get_message_content_object(content.get(), td_, date, is_content_secret)));
|
||||||
}
|
}
|
||||||
if (has_date && !td_->auth_manager_->is_bot()) {
|
if (has_date && is_user) {
|
||||||
Dialog *d = get_service_notifications_dialog();
|
Dialog *d = get_service_notifications_dialog();
|
||||||
CHECK(d != nullptr);
|
CHECK(d != nullptr);
|
||||||
auto dialog_id = d->dialog_id;
|
auto dialog_id = d->dialog_id;
|
||||||
|
@ -638,11 +638,26 @@ void UpdatesManager::on_get_updates(tl_object_ptr<telegram_api::Updates> &&updat
|
|||||||
LOG(INFO) << "Receive " << to_string(updates_ptr);
|
LOG(INFO) << "Receive " << to_string(updates_ptr);
|
||||||
}
|
}
|
||||||
if (!td_->auth_manager_->is_authorized()) {
|
if (!td_->auth_manager_->is_authorized()) {
|
||||||
if (updates_type == telegram_api::updateShort::ID &&
|
if (updates_type == telegram_api::updateShort::ID && !G()->close_flag()) {
|
||||||
static_cast<const telegram_api::updateShort *>(updates_ptr.get())->update_->get_id() ==
|
auto &update = static_cast<telegram_api::updateShort *>(updates_ptr.get())->update_;
|
||||||
telegram_api::updateLoginToken::ID) {
|
auto update_id = update->get_id();
|
||||||
|
if (update_id == telegram_api::updateLoginToken::ID) {
|
||||||
return td_->auth_manager_->on_update_login_token();
|
return td_->auth_manager_->on_update_login_token();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (update_id) {
|
||||||
|
case telegram_api::updateServiceNotification::ID:
|
||||||
|
case telegram_api::updateDcOptions::ID:
|
||||||
|
case telegram_api::updateConfig::ID:
|
||||||
|
case telegram_api::updateLangPackTooLong::ID:
|
||||||
|
case telegram_api::updateLangPack::ID:
|
||||||
|
LOG(INFO) << "Apply without authorization " << to_string(updates_ptr);
|
||||||
|
downcast_call(*update, OnUpdate(this, update, false));
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
LOG(INFO) << "Ignore received before authorization or after logout " << to_string(updates_ptr);
|
LOG(INFO) << "Ignore received before authorization or after logout " << to_string(updates_ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user