Don't generate MASK for parsed True fields.

This commit is contained in:
levlam 2021-11-01 21:53:23 +03:00
parent 4533f79338
commit 0c1e268706
28 changed files with 111 additions and 139 deletions

View File

@ -179,7 +179,7 @@ bool TD_TL_writer_h::need_arg_mask(const tl::arg &a, bool can_be_stored) const {
const tl::tl_tree_type *tree_type = static_cast<tl::tl_tree_type *>(a.type);
const std::string &name = tree_type->type->name;
if (!is_built_in_simple_type(name)) {
if (!is_built_in_simple_type(name) || name == "True") {
return false;
}
return true;
@ -201,7 +201,7 @@ std::string TD_TL_writer_h::gen_flags_definitions(const tl::tl_combinator *t, bo
}
std::string res;
if (!flags.empty()) {
res += " enum Flags : std::int32_t {";
res += " enum Flags : std::int32_t { ";
bool first = true;
for (auto &p : flags) {
if (first) {
@ -211,7 +211,7 @@ std::string TD_TL_writer_h::gen_flags_definitions(const tl::tl_combinator *t, bo
}
res += p.first + "_MASK = " + int_to_string(1 << p.second);
}
res += "};\n";
res += " };\n";
}
return res;
}

View File

@ -568,8 +568,7 @@ void AuthManager::on_get_password_result(NetQueryPtr &result) {
wait_password_state_.srp_B_ = password->srp_B_.as_slice().str();
wait_password_state_.srp_id_ = password->srp_id_;
wait_password_state_.hint_ = std::move(password->hint_);
wait_password_state_.has_recovery_ =
(password->flags_ & telegram_api::account_password::HAS_RECOVERY_MASK) != 0;
wait_password_state_.has_recovery_ = password->has_recovery_;
break;
}
default:

View File

@ -1098,8 +1098,8 @@ std::pair<BackgroundId, BackgroundType> BackgroundManager::on_get_background(
Background background;
background.id = background_id;
background.is_creator = false;
background.is_default = (wallpaper->flags_ & telegram_api::wallPaperNoFile::DEFAULT_MASK) != 0;
background.is_dark = (wallpaper->flags_ & telegram_api::wallPaperNoFile::DARK_MASK) != 0;
background.is_default = wallpaper->default_;
background.is_dark = wallpaper->dark_;
background.type = BackgroundType(true, false, std::move(wallpaper->settings_));
background.name = background.type.get_link();
add_background(background, replace_type);
@ -1124,8 +1124,7 @@ std::pair<BackgroundId, BackgroundType> BackgroundManager::on_get_background(
}
CHECK(document_id == telegram_api::document::ID);
int32 flags = wallpaper->flags_;
bool is_pattern = (flags & telegram_api::wallPaper::PATTERN_MASK) != 0;
bool is_pattern = wallpaper->pattern_;
Document document = td_->documents_manager_->on_get_document(
telegram_api::move_object_as<telegram_api::document>(wallpaper->document_), DialogId(), nullptr,
@ -1139,9 +1138,9 @@ std::pair<BackgroundId, BackgroundType> BackgroundManager::on_get_background(
Background background;
background.id = background_id;
background.access_hash = wallpaper->access_hash_;
background.is_creator = (flags & telegram_api::wallPaper::CREATOR_MASK) != 0;
background.is_default = (flags & telegram_api::wallPaper::DEFAULT_MASK) != 0;
background.is_dark = (flags & telegram_api::wallPaper::DARK_MASK) != 0;
background.is_creator = wallpaper->creator_;
background.is_default = wallpaper->default_;
background.is_dark = wallpaper->dark_;
background.type = BackgroundType(false, is_pattern, std::move(wallpaper->settings_));
background.name = std::move(wallpaper->slug_);
background.file_id = document.file_id;

View File

@ -378,7 +378,7 @@ Status CallActor::do_update_call(telegram_api::phoneCallWaiting &call) {
call_id_ = call.id_;
call_access_hash_ = call.access_hash_;
is_call_id_inited_ = true;
is_video_ |= (call.flags_ & telegram_api::phoneCallWaiting::VIDEO_MASK) != 0;
is_video_ |= call.video_;
call_admin_user_id_ = UserId(call.admin_id_);
// call_participant_user_id_ = UserId(call.participant_id_);
if (call_id_promise_) {
@ -401,7 +401,7 @@ Status CallActor::do_update_call(telegram_api::phoneCallRequested &call) {
call_id_ = call.id_;
call_access_hash_ = call.access_hash_;
is_call_id_inited_ = true;
is_video_ |= (call.flags_ & telegram_api::phoneCallRequested::VIDEO_MASK) != 0;
is_video_ |= call.video_;
call_admin_user_id_ = UserId(call.admin_id_);
// call_participant_user_id_ = UserId(call.participant_id_);
if (call_id_promise_) {
@ -441,7 +441,7 @@ Status CallActor::do_update_call(telegram_api::phoneCallAccepted &call) {
call_id_promise_.set_value(std::move(call.id_));
}
}
is_video_ |= (call.flags_ & telegram_api::phoneCallAccepted::VIDEO_MASK) != 0;
is_video_ |= call.video_;
dh_handshake_.set_g_a(call.g_b_.as_slice());
TRY_STATUS(dh_handshake_.run_checks(true, DhCache::instance()));
std::tie(call_state_.key_fingerprint, call_state_.key) = dh_handshake_.gen_key();
@ -465,7 +465,7 @@ Status CallActor::do_update_call(telegram_api::phoneCall &call) {
}
cancel_timeout();
is_video_ |= (call.flags_ & telegram_api::phoneCall::VIDEO_MASK) != 0;
is_video_ |= call.video_;
LOG(DEBUG) << "Do update call to Ready from state " << static_cast<int32>(state_);
if (state_ == State::WaitAcceptResult) {
@ -484,7 +484,7 @@ Status CallActor::do_update_call(telegram_api::phoneCall &call) {
call_state_.connections.emplace_back(*connection);
}
call_state_.protocol = CallProtocol(*call.protocol_);
call_state_.allow_p2p = (call.flags_ & telegram_api::phoneCall::P2P_ALLOWED_MASK) != 0;
call_state_.allow_p2p = call.p2p_allowed_;
call_state_.type = CallState::Type::Ready;
call_state_need_flush_ = true;

View File

@ -79,8 +79,8 @@ class GetBotCallbackAnswerQuery final : public Td::ResultHandler {
}
auto answer = result_ptr.move_as_ok();
bool show_alert = (answer->flags_ & telegram_api::messages_botCallbackAnswer::ALERT_MASK) != 0;
promise_.set_value(td_api::make_object<td_api::callbackQueryAnswer>(answer->message_, show_alert, answer->url_));
promise_.set_value(
td_api::make_object<td_api::callbackQueryAnswer>(answer->message_, answer->alert_, answer->url_));
}
void on_error(uint64 id, Status status) final {

View File

@ -1369,8 +1369,7 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
shared_config.set_option_integer("pinned_chat_count_max", config->pinned_dialogs_count_max_);
shared_config.set_option_integer("pinned_archived_chat_count_max", config->pinned_infolder_count_max_);
if (is_from_main_dc || !shared_config.have_option("expect_blocking")) {
shared_config.set_option_boolean("expect_blocking",
(config->flags_ & telegram_api::config::BLOCKED_MODE_MASK) != 0);
shared_config.set_option_boolean("expect_blocking", config->blocked_mode_);
}
if (is_from_main_dc || !shared_config.have_option("dc_txt_domain_name")) {
shared_config.set_option_string("dc_txt_domain_name", config->dc_txt_domain_name_);
@ -1404,8 +1403,7 @@ void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
if (is_from_main_dc) {
shared_config.set_option_integer("edit_time_limit", config->edit_time_limit_);
shared_config.set_option_boolean("revoke_pm_inbox",
(config->flags_ & telegram_api::config::REVOKE_PM_INBOX_MASK) != 0);
shared_config.set_option_boolean("revoke_pm_inbox", config->revoke_pm_inbox_);
shared_config.set_option_integer("revoke_time_limit", config->revoke_time_limit_);
shared_config.set_option_integer("revoke_pm_time_limit", config->revoke_pm_time_limit_);

View File

@ -5307,15 +5307,11 @@ void ContactsManager::get_account_ttl(Promise<int32> &&promise) const {
td_api::object_ptr<td_api::session> ContactsManager::convert_authorization_object(
tl_object_ptr<telegram_api::authorization> &&authorization) {
CHECK(authorization != nullptr);
bool is_current = (authorization->flags_ & telegram_api::authorization::CURRENT_MASK) != 0;
bool is_official_application = (authorization->flags_ & telegram_api::authorization::OFFICIAL_APP_MASK) != 0;
bool is_password_pending = (authorization->flags_ & telegram_api::authorization::PASSWORD_PENDING_MASK) != 0;
return td_api::make_object<td_api::session>(
authorization->hash_, is_current, is_password_pending, authorization->api_id_, authorization->app_name_,
authorization->app_version_, is_official_application, authorization->device_model_, authorization->platform_,
authorization->system_version_, authorization->date_created_, authorization->date_active_, authorization->ip_,
authorization->country_, authorization->region_);
authorization->hash_, authorization->current_, authorization->password_pending_, authorization->api_id_,
authorization->app_name_, authorization->app_version_, authorization->official_app_, authorization->device_model_,
authorization->platform_, authorization->system_version_, authorization->date_created_,
authorization->date_active_, authorization->ip_, authorization->country_, authorization->region_);
}
void ContactsManager::confirm_qr_code_authentication(const string &link,
@ -8684,8 +8680,7 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
if ((u == nullptr || !u->is_received) &&
(user_id == get_service_notifications_user_id() || user_id == get_replies_bot_user_id() ||
user_id == get_anonymous_bot_user_id())) {
int32 flags = telegram_api::user::ACCESS_HASH_MASK | telegram_api::user::FIRST_NAME_MASK |
telegram_api::user::APPLY_MIN_PHOTO_MASK;
int32 flags = USER_FLAG_HAS_ACCESS_HASH | USER_FLAG_HAS_FIRST_NAME | USER_FLAG_NEED_APPLY_MIN_PHOTO;
int64 profile_photo_id = 0;
int32 profile_photo_dc_id = 1;
string first_name;
@ -8695,26 +8690,26 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
int32 bot_info_version = 0;
if (user_id == get_service_notifications_user_id()) {
flags |= telegram_api::user::PHONE_MASK | telegram_api::user::VERIFIED_MASK | telegram_api::user::SUPPORT_MASK;
flags |= USER_FLAG_HAS_PHONE_NUMBER | USER_FLAG_IS_VERIFIED | USER_FLAG_IS_SUPPORT;
first_name = "Telegram";
if (G()->is_test_dc()) {
flags |= telegram_api::user::LAST_NAME_MASK;
flags |= USER_FLAG_HAS_LAST_NAME;
last_name = "Notifications";
}
phone_number = "42777";
profile_photo_id = 3337190045231023;
} else if (user_id == get_replies_bot_user_id()) {
flags |= telegram_api::user::USERNAME_MASK | telegram_api::user::BOT_MASK;
flags |= USER_FLAG_HAS_USERNAME | USER_FLAG_IS_BOT;
if (!G()->is_test_dc()) {
flags |= telegram_api::user::BOT_NOCHATS_MASK;
flags |= USER_FLAG_IS_PRIVATE_BOT;
}
first_name = "Replies";
username = "replies";
bot_info_version = G()->is_test_dc() ? 1 : 3;
} else if (user_id == get_anonymous_bot_user_id()) {
flags |= telegram_api::user::USERNAME_MASK | telegram_api::user::BOT_MASK;
flags |= USER_FLAG_HAS_USERNAME | USER_FLAG_IS_BOT;
if (!G()->is_test_dc()) {
flags |= telegram_api::user::BOT_NOCHATS_MASK;
flags |= USER_FLAG_IS_PRIVATE_BOT;
}
first_name = "Group";
username = G()->is_test_dc() ? "izgroupbot" : "GroupAnonymousBot";
@ -10374,8 +10369,8 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
}
on_update_user_full_common_chat_count(user_full, user_id, user->common_chats_count_);
on_update_user_full_need_phone_number_privacy_exception(
user_full, user_id, (user->settings_->flags_ & telegram_api::peerSettings::NEED_CONTACTS_EXCEPTION_MASK) != 0);
on_update_user_full_need_phone_number_privacy_exception(user_full, user_id,
user->settings_->need_contacts_exception_);
bool can_pin_messages = user->can_pin_message_;
if (user_full->can_pin_messages != can_pin_messages) {

View File

@ -711,16 +711,15 @@ DialogParticipant::DialogParticipant(tl_object_ptr<telegram_api::ChannelParticip
}
case telegram_api::channelParticipantCreator::ID: {
auto participant = move_tl_object_as<telegram_api::channelParticipantCreator>(participant_ptr);
bool is_anonymous = (participant->admin_rights_->flags_ & telegram_api::chatAdminRights::ANONYMOUS_MASK) != 0;
*this = {DialogId(UserId(participant->user_id_)), UserId(), 0,
DialogParticipantStatus::Creator(true, is_anonymous, std::move(participant->rank_))};
DialogParticipantStatus::Creator(true, participant->admin_rights_->anonymous_,
std::move(participant->rank_))};
break;
}
case telegram_api::channelParticipantAdmin::ID: {
auto participant = move_tl_object_as<telegram_api::channelParticipantAdmin>(participant_ptr);
bool can_be_edited = (participant->flags_ & telegram_api::channelParticipantAdmin::CAN_EDIT_MASK) != 0;
*this = {DialogId(UserId(participant->user_id_)), UserId(participant->promoted_by_), participant->date_,
get_dialog_participant_status(can_be_edited, std::move(participant->admin_rights_),
get_dialog_participant_status(participant->can_edit_, std::move(participant->admin_rights_),
std::move(participant->rank_))};
break;
}
@ -731,9 +730,8 @@ DialogParticipant::DialogParticipant(tl_object_ptr<telegram_api::ChannelParticip
}
case telegram_api::channelParticipantBanned::ID: {
auto participant = move_tl_object_as<telegram_api::channelParticipantBanned>(participant_ptr);
auto is_member = (participant->flags_ & telegram_api::channelParticipantBanned::LEFT_MASK) == 0;
*this = {DialogId(participant->peer_), UserId(participant->kicked_by_), participant->date_,
get_dialog_participant_status(is_member, std::move(participant->banned_rights_))};
get_dialog_participant_status(!participant->left_, std::move(participant->banned_rights_))};
break;
}
default:

View File

@ -55,7 +55,7 @@ unique_ptr<DraftMessage> get_draft_message(ContactsManager *contacts_manager,
entities = find_entities(draft->message_, false, true);
}
result->input_message_text.text = FormattedText{std::move(draft->message_), std::move(entities)};
result->input_message_text.disable_web_page_preview = (flags & telegram_api::draftMessage::NO_WEBPAGE_MASK) != 0;
result->input_message_text.disable_web_page_preview = draft->no_webpage_;
result->input_message_text.clear_draft = false;
return result;

View File

@ -32,7 +32,7 @@ GroupCallParticipant::GroupCallParticipant(const tl_object_ptr<telegram_api::gro
LOG(ERROR) << "Receive " << to_string(participant);
volume_level = 10000;
}
is_volume_level_local = (participant->flags_ & telegram_api::groupCallParticipant::VOLUME_BY_ADMIN_MASK) == 0;
is_volume_level_local = !participant->volume_by_admin_;
}
if (!participant->left_) {
joined_date = participant->date_;

View File

@ -1605,9 +1605,9 @@ Result<LanguagePackManager::LanguageInfo> LanguagePackManager::get_language_info
info.native_name_ = std::move(language->native_name_);
info.base_language_code_ = std::move(language->base_lang_code_);
info.plural_code_ = std::move(language->plural_code_);
info.is_official_ = (language->flags_ & telegram_api::langPackLanguage::OFFICIAL_MASK) != 0;
info.is_rtl_ = (language->flags_ & telegram_api::langPackLanguage::RTL_MASK) != 0;
info.is_beta_ = (language->flags_ & telegram_api::langPackLanguage::BETA_MASK) != 0;
info.is_official_ = language->official_;
info.is_rtl_ = language->rtl_;
info.is_beta_ = language->beta_;
info.is_from_database_ = false;
info.total_string_count_ = language->strings_count_;
info.translated_string_count_ = language->translated_count_;

View File

@ -401,8 +401,6 @@ class GetDeepLinkInfoQuery final : public Td::ResultHandler {
return promise_.set_value(nullptr);
case telegram_api::help_deepLinkInfo::ID: {
auto info = telegram_api::move_object_as<telegram_api::help_deepLinkInfo>(result);
bool need_update = (info->flags_ & telegram_api::help_deepLinkInfo::UPDATE_APP_MASK) != 0;
auto entities = get_message_entities(nullptr, std::move(info->entities_), "GetDeepLinkInfoQuery");
auto status = fix_formatted_text(info->message_, entities, true, true, true, true, true);
if (status.is_error()) {
@ -414,7 +412,7 @@ class GetDeepLinkInfoQuery final : public Td::ResultHandler {
}
FormattedText text{std::move(info->message_), std::move(entities)};
return promise_.set_value(
td_api::make_object<td_api::deepLinkInfo>(get_formatted_text_object(text, true, -1), need_update));
td_api::make_object<td_api::deepLinkInfo>(get_formatted_text_object(text, true, -1), info->update_app_));
}
default:
UNREACHABLE();
@ -469,11 +467,9 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
return on_error(id, Status::Error(500, "Receive invalid bot_user_id"));
}
td->contacts_manager_->on_get_user(std::move(request->bot_), "RequestUrlAuthQuery");
bool request_write_access =
(request->flags_ & telegram_api::urlAuthResultRequest::REQUEST_WRITE_ACCESS_MASK) != 0;
promise_.set_value(td_api::make_object<td_api::loginUrlInfoRequestConfirmation>(
url_, request->domain_, td->contacts_manager_->get_user_id_object(bot_user_id, "RequestUrlAuthQuery"),
request_write_access));
request->request_write_access_));
break;
}
case telegram_api::urlAuthResultAccepted::ID: {

View File

@ -1512,8 +1512,7 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id,
break;
}
result.disable_web_page_preview =
(inline_message->flags_ & telegram_api::botInlineMessageText::NO_WEBPAGE_MASK) != 0;
result.disable_web_page_preview = inline_message->no_webpage_;
WebPageId web_page_id;
if (!result.disable_web_page_preview) {
web_page_id = td->web_pages_manager_->get_web_page_by_url(get_first_url(inline_message->message_, entities));
@ -4635,13 +4634,12 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
auto phone_call = move_tl_object_as<telegram_api::messageActionPhoneCall>(action);
auto duration =
(phone_call->flags_ & telegram_api::messageActionPhoneCall::DURATION_MASK) != 0 ? phone_call->duration_ : 0;
auto is_video = (phone_call->flags_ & telegram_api::messageActionPhoneCall::VIDEO_MASK) != 0;
if (duration < 0) {
LOG(ERROR) << "Receive invalid " << oneline(to_string(phone_call));
break;
}
return make_unique<MessageCall>(phone_call->call_id_, duration, get_call_discard_reason(phone_call->reason_),
is_video);
phone_call->video_);
}
case telegram_api::messageActionPaymentSent::ID: {
if (td->auth_manager_->is_bot()) {

View File

@ -6667,7 +6667,7 @@ void MessagesManager::on_update_service_notification(tl_object_ptr<telegram_api:
UserId(), &ttl);
bool is_content_secret = is_secret_message_content(ttl, content->get_type());
if ((update->flags_ & telegram_api::updateServiceNotification::POPUP_MASK) != 0) {
if (update->popup_) {
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateServiceNotification>(
update->type_, get_message_content_object(content.get(), td_, owner_dialog_id, date,
@ -8474,10 +8474,8 @@ void MessagesManager::on_get_peer_settings(DialogId dialog_id,
bool ignore_privacy_exception) {
CHECK(peer_settings != nullptr);
if (dialog_id.get_type() == DialogType::User && !ignore_privacy_exception) {
auto need_phone_number_privacy_exception =
(peer_settings->flags_ & telegram_api::peerSettings::NEED_CONTACTS_EXCEPTION_MASK) != 0;
td_->contacts_manager_->on_update_user_need_phone_number_privacy_exception(dialog_id.get_user_id(),
need_phone_number_privacy_exception);
peer_settings->need_contacts_exception_);
}
Dialog *d = get_dialog_force(dialog_id, "on_get_peer_settings");
@ -8485,15 +8483,15 @@ void MessagesManager::on_get_peer_settings(DialogId dialog_id,
return;
}
auto can_report_spam = (peer_settings->flags_ & telegram_api::peerSettings::REPORT_SPAM_MASK) != 0;
auto can_add_contact = (peer_settings->flags_ & telegram_api::peerSettings::ADD_CONTACT_MASK) != 0;
auto can_block_user = (peer_settings->flags_ & telegram_api::peerSettings::BLOCK_CONTACT_MASK) != 0;
auto can_share_phone_number = (peer_settings->flags_ & telegram_api::peerSettings::SHARE_CONTACT_MASK) != 0;
auto can_report_location = (peer_settings->flags_ & telegram_api::peerSettings::REPORT_GEO_MASK) != 0;
auto can_unarchive = (peer_settings->flags_ & telegram_api::peerSettings::AUTOARCHIVED_MASK) != 0;
auto can_report_spam = peer_settings->report_spam_;
auto can_add_contact = peer_settings->add_contact_;
auto can_block_user = peer_settings->block_contact_;
auto can_share_phone_number = peer_settings->share_contact_;
auto can_report_location = peer_settings->report_geo_;
auto can_unarchive = peer_settings->autoarchived_;
auto distance =
(peer_settings->flags_ & telegram_api::peerSettings::GEO_DISTANCE_MASK) != 0 ? peer_settings->geo_distance_ : -1;
auto can_invite_members = (peer_settings->flags_ & telegram_api::peerSettings::INVITE_MEMBERS_MASK) != 0;
auto can_invite_members = peer_settings->invite_members_;
if (d->can_report_spam == can_report_spam && d->can_add_contact == can_add_contact &&
d->can_block_user == can_block_user && d->can_share_phone_number == can_share_phone_number &&
d->can_report_location == can_report_location && d->can_unarchive == can_unarchive && d->distance == distance &&
@ -14875,7 +14873,7 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vector<tl_object_ptr<te
set_channel_pts(d, dialog->pts_, "get channel");
}
}
bool is_marked_as_unread = (dialog->flags_ & telegram_api::dialog::UNREAD_MARK_MASK) != 0;
bool is_marked_as_unread = dialog->unread_mark_;
if (is_marked_as_unread != d->is_marked_as_unread) {
set_dialog_is_marked_as_unread(d, is_marked_as_unread);
}
@ -37202,7 +37200,7 @@ void MessagesManager::on_get_channel_difference(
on_update_dialog_notify_settings(dialog_id, std::move(dialog->notify_settings_),
"updates.channelDifferenceTooLong");
bool is_marked_as_unread = (dialog->flags_ & telegram_api::dialog::UNREAD_MARK_MASK) != 0;
bool is_marked_as_unread = dialog->unread_mark_;
if (is_marked_as_unread != d->is_marked_as_unread) {
set_dialog_is_marked_as_unread(d, is_marked_as_unread);
}

View File

@ -3275,10 +3275,10 @@ Status NotificationManager::process_push_notification_payload(string payload, bo
}
}
int32 flags = telegram_api::user::FIRST_NAME_MASK | telegram_api::user::MIN_MASK;
int32 flags = USER_FLAG_IS_INACCESSIBLE;
if (sender_access_hash != -1) {
// set phone number flag to show that this is a full access hash
flags |= telegram_api::user::ACCESS_HASH_MASK | telegram_api::user::PHONE_MASK;
flags |= USER_FLAG_HAS_ACCESS_HASH | USER_FLAG_HAS_PHONE_NUMBER;
}
auto user_name = sender_user_id.get() == 136817688 ? "Channel" : sender_name;
auto user = telegram_api::make_object<telegram_api::user>(
@ -3616,7 +3616,7 @@ void NotificationManager::add_message_push_notification(DialogId dialog_id, Mess
}
if (sender_user_id.is_valid() && !td_->contacts_manager_->have_user_force(sender_user_id)) {
int32 flags = telegram_api::user::FIRST_NAME_MASK | telegram_api::user::MIN_MASK;
int32 flags = USER_FLAG_IS_INACCESSIBLE;
auto user_name = sender_user_id.get() == 136817688 ? "Channel" : sender_name;
auto user = telegram_api::make_object<telegram_api::user>(
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,

View File

@ -150,6 +150,10 @@ class NotificationManager final : public Actor {
static constexpr int32 ANNOUNCEMENT_ID_CACHE_TIME = 7 * 86400;
static constexpr int32 USER_FLAG_HAS_ACCESS_HASH = 1 << 0;
static constexpr int32 USER_FLAG_HAS_PHONE_NUMBER = 1 << 4;
static constexpr int32 USER_FLAG_IS_INACCESSIBLE = 1 << 20;
class AddMessagePushNotificationLogEvent;
class EditMessagePushNotificationLogEvent;

View File

@ -778,9 +778,8 @@ void PasswordManager::do_get_state(Promise<PasswordState> promise) {
state.current_srp_B = password->srp_B_.as_slice().str();
state.current_srp_id = password->srp_id_;
state.password_hint = std::move(password->hint_);
state.has_recovery_email_address =
(password->flags_ & telegram_api::account_password::HAS_RECOVERY_MASK) != 0;
state.has_secure_values = (password->flags_ & telegram_api::account_password::HAS_SECURE_VALUES_MASK) != 0;
state.has_recovery_email_address = password->has_recovery_;
state.has_secure_values = password->has_secure_values_;
} else {
state.has_password = false;
send_closure(actor_id, &PasswordManager::drop_cached_secret);

View File

@ -304,9 +304,8 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
LOG(ERROR) << "Receive invalid seller " << seller_bot_user_id;
return on_error(id, Status::Error(500, "Receive invalid seller identifier"));
}
bool can_save_credentials =
(payment_form->flags_ & telegram_api::payments_paymentForm::CAN_SAVE_CREDENTIALS_MASK) != 0;
bool need_password = (payment_form->flags_ & telegram_api::payments_paymentForm::PASSWORD_MISSING_MASK) != 0;
bool can_save_credentials = payment_form->can_save_credentials_;
bool need_password = payment_form->password_missing_;
promise_.set_value(make_tl_object<td_api::paymentForm>(
payment_form->form_id_, convert_invoice(std::move(payment_form->invoice_)), std::move(payment_form->url_),
td->contacts_manager_->get_user_id_object(seller_bot_user_id, "paymentForm seller"),
@ -649,9 +648,8 @@ InputInvoice get_input_invoice(tl_object_ptr<telegram_api::messageMediaInvoice>
result.photo = get_web_document_photo(td->file_manager_.get(), std::move(message_invoice->photo_), owner_dialog_id);
result.start_parameter = std::move(message_invoice->start_param_);
result.invoice.currency = std::move(message_invoice->currency_);
result.invoice.is_test = (message_invoice->flags_ & telegram_api::messageMediaInvoice::TEST_MASK) != 0;
result.invoice.need_shipping_address =
(message_invoice->flags_ & telegram_api::messageMediaInvoice::SHIPPING_ADDRESS_REQUESTED_MASK) != 0;
result.invoice.is_test = message_invoice->test_;
result.invoice.need_shipping_address = message_invoice->shipping_address_requested_;
// result.payload = string();
// result.provider_token = string();
// result.provider_data = string();
@ -674,9 +672,8 @@ InputInvoice get_input_invoice(tl_object_ptr<telegram_api::botInlineMessageMedia
result.photo = get_web_document_photo(td->file_manager_.get(), std::move(message_invoice->photo_), owner_dialog_id);
// result.start_parameter = string();
result.invoice.currency = std::move(message_invoice->currency_);
result.invoice.is_test = (message_invoice->flags_ & telegram_api::messageMediaInvoice::TEST_MASK) != 0;
result.invoice.need_shipping_address =
(message_invoice->flags_ & telegram_api::messageMediaInvoice::SHIPPING_ADDRESS_REQUESTED_MASK) != 0;
result.invoice.is_test = message_invoice->test_;
result.invoice.need_shipping_address = message_invoice->shipping_address_requested_;
// result.payload = string();
// result.provider_token = string();
// result.provider_data = string();

View File

@ -159,7 +159,7 @@ ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64
auto profile_photo = move_tl_object_as<telegram_api::userProfilePhoto>(profile_photo_ptr);
auto dc_id = DcId::create(profile_photo->dc_id_);
result.has_animation = (profile_photo->flags_ & telegram_api::userProfilePhoto::HAS_VIDEO_MASK) != 0;
result.has_animation = profile_photo->has_video_;
result.id = profile_photo->photo_id_;
result.minithumbnail = profile_photo->stripped_thumb_.as_slice().str();
result.small_file_id = register_photo(
@ -221,7 +221,7 @@ DialogPhoto get_dialog_photo(FileManager *file_manager, DialogId dialog_id, int6
auto chat_photo = move_tl_object_as<telegram_api::chatPhoto>(chat_photo_ptr);
auto dc_id = DcId::create(chat_photo->dc_id_);
result.has_animation = (chat_photo->flags_ & telegram_api::chatPhoto::HAS_VIDEO_MASK) != 0;
result.has_animation = chat_photo->has_video_;
result.minithumbnail = chat_photo->stripped_thumb_.as_slice().str();
result.small_file_id =
register_photo(file_manager, PhotoSizeSource::dialog_photo(dialog_id, dialog_access_hash, false),
@ -702,7 +702,7 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&
res.id = photo->id_;
res.date = photo->date_;
res.has_stickers = (photo->flags_ & telegram_api::photo::HAS_STICKERS_MASK) != 0;
res.has_stickers = photo->has_stickers_;
if (res.is_empty()) {
LOG(ERROR) << "Receive photo with identifier " << res.id.get();
@ -977,12 +977,8 @@ tl_object_ptr<telegram_api::userProfilePhoto> convert_photo_to_profile_photo(
if (!have_photo_small || !have_photo_big) {
return nullptr;
}
int32 flags = 0;
if (!photo->video_sizes_.empty()) {
flags |= telegram_api::userProfilePhoto::HAS_VIDEO_MASK;
}
return make_tl_object<telegram_api::userProfilePhoto>(flags, false /*ignored*/, photo->id_, BufferSlice(),
photo->dc_id_);
bool has_video = !photo->video_sizes_.empty();
return make_tl_object<telegram_api::userProfilePhoto>(0, has_video, photo->id_, BufferSlice(), photo->dc_id_);
}
} // namespace td

View File

@ -1490,7 +1490,7 @@ PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll
}
CHECK(poll_results != nullptr);
bool is_min = (poll_results->flags_ & telegram_api::pollResults::MIN_MASK) != 0;
bool is_min = poll_results->min_;
bool has_total_voters = (poll_results->flags_ & telegram_api::pollResults::TOTAL_VOTERS_MASK) != 0;
if (has_total_voters && poll_results->total_voters_ != poll->total_voter_count) {
poll->total_voter_count = poll_results->total_voters_;
@ -1509,14 +1509,14 @@ PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll
continue;
}
if (!is_min) {
bool is_chosen = (poll_result->flags_ & telegram_api::pollAnswerVoters::CHOSEN_MASK) != 0;
bool is_chosen = poll_result->chosen_;
if (is_chosen != option.is_chosen) {
option.is_chosen = is_chosen;
is_changed = true;
}
}
if (!is_min || poll_server_is_closed) {
bool is_correct = (poll_result->flags_ & telegram_api::pollAnswerVoters::CORRECT_MASK) != 0;
bool is_correct = poll_result->correct_;
if (is_correct) {
if (correct_option_id != -1) {
LOG(ERROR) << "Receive more than 1 correct answers " << correct_option_id << " and " << option_index;

View File

@ -242,10 +242,9 @@ SuitableSecureValue get_suitable_secure_value(
const tl_object_ptr<telegram_api::secureRequiredType> &secure_required_type) {
SuitableSecureValue result;
result.type = get_secure_value_type(secure_required_type->type_);
auto flags = secure_required_type->flags_;
result.is_selfie_required = (flags & telegram_api::secureRequiredType::SELFIE_REQUIRED_MASK) != 0;
result.is_translation_required = (flags & telegram_api::secureRequiredType::TRANSLATION_REQUIRED_MASK) != 0;
result.is_native_name_required = (flags & telegram_api::secureRequiredType::NATIVE_NAMES_MASK) != 0;
result.is_selfie_required = secure_required_type->selfie_required_;
result.is_translation_required = secure_required_type->translation_required_;
result.is_native_name_required = secure_required_type->native_names_;
return result;
}

View File

@ -2690,10 +2690,10 @@ StickerSetId StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::sti
StickerSet *s = add_sticker_set(set_id, set->access_hash_);
bool is_installed = (set->flags_ & telegram_api::stickerSet::INSTALLED_DATE_MASK) != 0;
bool is_archived = (set->flags_ & telegram_api::stickerSet::ARCHIVED_MASK) != 0;
bool is_official = (set->flags_ & telegram_api::stickerSet::OFFICIAL_MASK) != 0;
bool is_animated = (set->flags_ & telegram_api::stickerSet::ANIMATED_MASK) != 0;
bool is_masks = (set->flags_ & telegram_api::stickerSet::MASKS_MASK) != 0;
bool is_archived = set->archived_;
bool is_official = set->official_;
bool is_animated = set->animated_;
bool is_masks = set->masks_;
PhotoSize thumbnail;
string minithumbnail;

View File

@ -2902,7 +2902,7 @@ void Td::on_get_promo_data(Result<telegram_api::object_ptr<telegram_api::help_Pr
case telegram_api::help_promoData::ID: {
auto promo = telegram_api::move_object_as<telegram_api::help_promoData>(promo_data_ptr);
expires_at = promo->expires_;
bool is_proxy = (promo->flags_ & telegram_api::help_promoData::PROXY_MASK) != 0;
bool is_proxy = promo->proxy_;
messages_manager_->on_get_sponsored_dialog(
std::move(promo->peer_),
is_proxy ? DialogSource::mtproto_proxy()

View File

@ -106,9 +106,8 @@ TermsOfService::TermsOfService(telegram_api::object_ptr<telegram_api::help_terms
id_.clear();
}
text_ = FormattedText{std::move(terms->text_), std::move(entities)};
min_user_age_ =
((terms->flags_ & telegram_api::help_termsOfService::MIN_AGE_CONFIRM_MASK) != 0 ? terms->min_age_confirm_ : 0);
show_popup_ = (terms->flags_ & telegram_api::help_termsOfService::POPUP_MASK) != 0;
min_user_age_ = terms->min_age_confirm_;
show_popup_ = terms->popup_;
}
void get_terms_of_service(Td *td, Promise<std::pair<int32, TermsOfService>> promise) {

View File

@ -56,6 +56,7 @@ TopDialogCategory get_top_dialog_category(const td_api::object_ptr<td_api::TopCh
return TopDialogCategory::Size;
}
}
TopDialogCategory get_top_dialog_category(const telegram_api::object_ptr<telegram_api::TopPeerCategory> &category) {
CHECK(category != nullptr);
switch (category->get_id()) {

View File

@ -2928,9 +2928,8 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDraftMessage> u
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDialogPinned> update, Promise<Unit> &&promise) {
FolderId folder_id(update->flags_ & telegram_api::updateDialogPinned::FOLDER_ID_MASK ? update->folder_id_ : 0);
td_->messages_manager_->on_update_dialog_is_pinned(
folder_id, DialogId(update->peer_), (update->flags_ & telegram_api::updateDialogPinned::PINNED_MASK) != 0);
td_->messages_manager_->on_update_dialog_is_pinned(FolderId(update->folder_id_), DialogId(update->peer_),
update->pinned_);
promise.set_value(Unit());
}
@ -2941,8 +2940,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updatePinnedDialogs>
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDialogUnreadMark> update, Promise<Unit> &&promise) {
td_->messages_manager_->on_update_dialog_is_marked_as_unread(
DialogId(update->peer_), (update->flags_ & telegram_api::updateDialogUnreadMark::UNREAD_MASK) != 0);
td_->messages_manager_->on_update_dialog_is_marked_as_unread(DialogId(update->peer_), update->unread_);
promise.set_value(Unit());
}
@ -3047,8 +3045,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateStickerSets> up
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateStickerSetsOrder> update, Promise<Unit> &&promise) {
bool is_masks = (update->flags_ & telegram_api::updateStickerSetsOrder::MASKS_MASK) != 0;
td_->stickers_manager_->on_update_sticker_sets_order(is_masks,
td_->stickers_manager_->on_update_sticker_sets_order(update->masks_,
StickersManager::convert_sticker_set_ids(update->order_));
promise.set_value(Unit());
}

View File

@ -2039,8 +2039,8 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
}
case telegram_api::pageBlockVideo::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockVideo>(page_block_ptr);
bool need_autoplay = (page_block->flags_ & telegram_api::pageBlockVideo::AUTOPLAY_MASK) != 0;
bool is_looped = (page_block->flags_ & telegram_api::pageBlockVideo::LOOP_MASK) != 0;
bool need_autoplay = page_block->autoplay_;
bool is_looped = page_block->loop_;
auto animations_it = animations.find(page_block->video_id_);
if (animations_it != animations.end()) {
LOG_IF(ERROR, !is_looped) << "Receive non-looped animation";
@ -2067,8 +2067,8 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
}
case telegram_api::pageBlockEmbed::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockEmbed>(page_block_ptr);
bool is_full_width = (page_block->flags_ & telegram_api::pageBlockEmbed::FULL_WIDTH_MASK) != 0;
bool allow_scrolling = (page_block->flags_ & telegram_api::pageBlockEmbed::ALLOW_SCROLLING_MASK) != 0;
bool is_full_width = page_block->full_width_;
bool allow_scrolling = page_block->allow_scrolling_;
bool has_dimensions = (page_block->flags_ & telegram_api::pageBlockEmbed::W_MASK) != 0;
auto it = (page_block->flags_ & telegram_api::pageBlockEmbed::POSTER_PHOTO_ID_MASK) != 0
? photos.find(page_block->poster_photo_id_)
@ -2158,23 +2158,22 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
}
case telegram_api::pageBlockTable::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockTable>(page_block_ptr);
auto is_bordered = (page_block->flags_ & telegram_api::pageBlockTable::BORDERED_MASK) != 0;
auto is_striped = (page_block->flags_ & telegram_api::pageBlockTable::STRIPED_MASK) != 0;
auto is_bordered = page_block->bordered_;
auto is_striped = page_block->striped_;
auto cells = transform(std::move(page_block->rows_), [&](tl_object_ptr<telegram_api::pageTableRow> &&row) {
return transform(std::move(row->cells_), [&](tl_object_ptr<telegram_api::pageTableCell> &&table_cell) {
WebPageBlockTableCell cell;
auto flags = table_cell->flags_;
cell.is_header = (flags & telegram_api::pageTableCell::HEADER_MASK) != 0;
cell.align_center = (flags & telegram_api::pageTableCell::ALIGN_CENTER_MASK) != 0;
cell.is_header = table_cell->header_;
cell.align_center = table_cell->align_center_;
if (!cell.align_center) {
cell.align_right = (flags & telegram_api::pageTableCell::ALIGN_RIGHT_MASK) != 0;
cell.align_right = table_cell->align_right_;
if (!cell.align_right) {
cell.align_left = true;
}
}
cell.valign_middle = (flags & telegram_api::pageTableCell::VALIGN_MIDDLE_MASK) != 0;
cell.valign_middle = table_cell->valign_middle_;
if (!cell.valign_middle) {
cell.valign_bottom = (flags & telegram_api::pageTableCell::VALIGN_BOTTOM_MASK) != 0;
cell.valign_bottom = table_cell->valign_bottom_;
if (!cell.valign_bottom) {
cell.valign_top = true;
}
@ -2182,10 +2181,10 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
if (table_cell->text_ != nullptr) {
cell.text = get_rich_text(std::move(table_cell->text_), documents);
}
if ((flags & telegram_api::pageTableCell::COLSPAN_MASK) != 0) {
if ((table_cell->flags_ & telegram_api::pageTableCell::COLSPAN_MASK) != 0) {
cell.colspan = table_cell->colspan_;
}
if ((flags & telegram_api::pageTableCell::ROWSPAN_MASK) != 0) {
if ((table_cell->flags_ & telegram_api::pageTableCell::ROWSPAN_MASK) != 0) {
cell.rowspan = table_cell->rowspan_;
}
return cell;
@ -2196,7 +2195,7 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
}
case telegram_api::pageBlockDetails::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockDetails>(page_block_ptr);
auto is_open = (page_block->flags_ & telegram_api::pageBlockDetails::OPEN_MASK) != 0;
auto is_open = page_block->open_;
return td::make_unique<WebPageBlockDetails>(get_rich_text(std::move(page_block->title_), documents),
get_web_page_blocks(td, std::move(page_block->blocks_), animations,
audios, documents, photos, videos, voice_notes),

View File

@ -1456,12 +1456,12 @@ void WebPagesManager::on_get_web_page_instant_view(WebPage *web_page, tl_object_
web_page->instant_view.page_blocks =
get_web_page_blocks(td_, std::move(page->blocks_), animations, audios, documents, photos, videos, voice_notes);
web_page->instant_view.view_count = (page->flags_ & telegram_api::page::VIEWS_MASK) != 0 ? page->views_ : 0;
web_page->instant_view.is_v2 = (page->flags_ & telegram_api::page::V2_MASK) != 0;
web_page->instant_view.is_rtl = (page->flags_ & telegram_api::page::RTL_MASK) != 0;
web_page->instant_view.is_v2 = page->v2_;
web_page->instant_view.is_rtl = page->rtl_;
web_page->instant_view.hash = hash;
web_page->instant_view.url = std::move(page->url_);
web_page->instant_view.is_empty = false;
web_page->instant_view.is_full = (page->flags_ & telegram_api::page::PART_MASK) == 0;
web_page->instant_view.is_full = !page->part_;
web_page->instant_view.is_loaded = true;
LOG(DEBUG) << "Receive web page instant view: "