From f1419395dfb843f2aae4d7857e5326c3968dfa0b Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 1 Mar 2019 05:35:01 +0300 Subject: [PATCH] Add user.is_support flag. GitOrigin-RevId: 6c1774d309eefdb20e75e2b01e07a4738efcde81 --- td/generate/scheme/td_api.tl | 6 +++-- td/generate/scheme/td_api.tlo | Bin 146440 -> 146476 bytes td/generate/scheme/telegram_api.tl | 2 +- td/generate/scheme/telegram_api.tlo | Bin 174468 -> 174508 bytes td/telegram/ContactsManager.cpp | 33 +++++++++++++++++----------- td/telegram/ContactsManager.h | 4 +++- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 84f18da8a..535179660 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -291,10 +291,12 @@ botInfo description:string commands:vector = BotInfo; //@description Represents a user @id User identifier @first_name First name of the user @last_name Last name of the user @username Username of the user //@phone_number Phone number of the user @status Current online status of the user @profile_photo Profile photo of the user; may be null -//@outgoing_link Relationship from the current user to the other user @incoming_link Relationship from the other user to the current user @is_verified True, if the user is verified @restriction_reason If non-empty, it contains the reason why access to this user must be restricted. The format of the string is "{type}: {description}". +//@outgoing_link Relationship from the current user to the other user @incoming_link Relationship from the other user to the current user +//@is_verified True, if the user is verified @is_support True, if the user is Telegram support account +//@restriction_reason If non-empty, it contains the reason why access to this user must be restricted. The format of the string is "{type}: {description}". //-{type} contains the type of the restriction and at least one of the suffixes "-all", "-ios", "-android", or "-wp", which describe the platforms on which access should be restricted. (For example, "terms-ios-android". {description} contains a human-readable description of the restriction, which can be shown to the user) //@have_access If false, the user is inaccessible, and the only information known about the user is inside this class. It can't be passed to any method except GetUser @type Type of the user @language_code IETF language tag of the user's language; only available to bots -user id:int32 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto outgoing_link:LinkState incoming_link:LinkState is_verified:Bool restriction_reason:string have_access:Bool type:UserType language_code:string = User; +user id:int32 first_name:string last_name:string username:string phone_number:string status:UserStatus profile_photo:profilePhoto outgoing_link:LinkState incoming_link:LinkState is_verified:Bool is_support:Bool restriction_reason:string have_access:Bool type:UserType language_code:string = User; //@description Contains full information about a user (except the full list of profile photos) @is_blocked True, if the user is blacklisted by the current user @can_be_called True, if the user can be called @has_private_calls True, if the user can't be called due to their privacy settings //@bio A short user bio @share_text For bots, the text that is included with the link when users share the bot @group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user @bot_info If the user is a bot, information about the bot; may be null diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 0e8c9823a214c456cbba524e4ea07e06f634e1cb..23bf8b4aeecc178a5fac3103ae6cdd83d8e7256d 100644 GIT binary patch delta 192 zcmeD9!LjBC$A%tdmQ}qM`I;vvZ=aydxWOCDo30SWsIWaHpYegPC`gv2v^cehfq?&5QwzoLrg3@x`SD1^JT&ZKS6MxG-u=(qNtbvxPAqY}EFgRz{a7 w37AfxAq+*%Y&smaZ3jVO+fUqQT)>B0y5SvT4kN@(7d#maAV#WuV0_{Y0P`bB)Bpeg delta 170 zcmZ4UgQMdI$A%tdmP-5BE6o#>w@*-J+~5u7O;?CwRM?)9&-g%C6eP=1TAW(Mz`y`v z-#jMd!#DY3q4M^cX2t-<=^t7c=YTbBpU}$a5+wms160mX26P(#(0fUkiEFHpdi1fgoyzH#HT+z$Y?zIK_gFl N$_&QsDKnT91Ob_>6m &&user_ptr, const char *source, bool is_me, - bool is_support) { + bool expect_support) { LOG(DEBUG) << "Receive from " << source << ' ' << to_string(user_ptr); int32 constructor_id = user_ptr->get_id(); if (constructor_id == telegram_api::userEmpty::ID) { @@ -5044,7 +5046,7 @@ void ContactsManager::on_get_user(tl_object_ptr &&user_ptr, */ } - if (is_support) { + if (expect_support) { support_user_id_ = user_id; } @@ -5088,6 +5090,7 @@ void ContactsManager::on_get_user(tl_object_ptr &&user_ptr, } bool is_verified = (flags & USER_FLAG_IS_VERIFIED) != 0; + bool is_support = (flags & USER_FLAG_IS_SUPPORT) != 0; bool is_deleted = (flags & USER_FLAG_IS_DELETED) != 0; bool can_join_groups = (flags & USER_FLAG_IS_PRIVATE_BOT) == 0; bool can_read_all_group_messages = (flags & USER_FLAG_IS_BOT_WITH_PRIVACY_DISABLED) != 0; @@ -5097,6 +5100,7 @@ void ContactsManager::on_get_user(tl_object_ptr &&user_ptr, bool need_location_bot = (flags & USER_FLAG_NEED_LOCATION_BOT) != 0; bool has_bot_info_version = (flags & USER_FLAG_HAS_BOT_INFO_VERSION) != 0; + LOG_IF(ERROR, !is_support && expect_support) << "Receive non-support " << user_id << ", but expected a support user"; LOG_IF(ERROR, !can_join_groups && !is_bot) << "Receive not bot " << user_id << " which can't join groups from " << source; LOG_IF(ERROR, can_read_all_group_messages && !is_bot) @@ -5115,6 +5119,7 @@ void ContactsManager::on_get_user(tl_object_ptr &&user_ptr, if (is_deleted) { // just in case is_verified = false; + is_support = false; is_bot = false; can_join_groups = false; can_read_all_group_messages = false; @@ -5128,14 +5133,15 @@ void ContactsManager::on_get_user(tl_object_ptr &&user_ptr, << "Receive not bot " << user_id << " which has bot info version from " << source; int32 bot_info_version = has_bot_info_version ? user->bot_info_version_ : -1; - if (is_verified != u->is_verified || is_bot != u->is_bot || can_join_groups != u->can_join_groups || - can_read_all_group_messages != u->can_read_all_group_messages || restriction_reason != u->restriction_reason || - is_inline_bot != u->is_inline_bot || inline_query_placeholder != u->inline_query_placeholder || - need_location_bot != u->need_location_bot) { + if (is_verified != u->is_verified || is_support != u->is_support || is_bot != u->is_bot || + can_join_groups != u->can_join_groups || can_read_all_group_messages != u->can_read_all_group_messages || + restriction_reason != u->restriction_reason || is_inline_bot != u->is_inline_bot || + inline_query_placeholder != u->inline_query_placeholder || need_location_bot != u->need_location_bot) { LOG_IF(ERROR, is_bot != u->is_bot && !is_deleted && !u->is_deleted) << "User.is_bot has changed for " << user_id << "/" << u->username << " from " << source << " from " << u->is_bot << " to " << is_bot; u->is_verified = is_verified; + u->is_support = is_support; u->is_bot = is_bot; u->can_join_groups = can_join_groups; u->can_read_all_group_messages = can_read_all_group_messages; @@ -5402,7 +5408,8 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) { auto u = get_user_force_impl(user_id); if (user_id == UserId(777000) && (u == nullptr || !u->is_received)) { int32 flags = telegram_api::user::ACCESS_HASH_MASK | telegram_api::user::FIRST_NAME_MASK | - telegram_api::user::PHONE_MASK | telegram_api::user::PHOTO_MASK | telegram_api::user::VERIFIED_MASK; + telegram_api::user::PHONE_MASK | telegram_api::user::PHOTO_MASK | telegram_api::user::VERIFIED_MASK | + telegram_api::user::SUPPORT_MASK; auto profile_photo = telegram_api::make_object( 3337190045231018, telegram_api::make_object(1, 702229962, 26779, 5859320227133863146, BufferSlice()), @@ -5416,8 +5423,8 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) { auto user = telegram_api::make_object( flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, - false /*ignored*/, 777000, 1, "Telegram", "Updates", string(), "42777", std::move(profile_photo), nullptr, 0, - string(), string(), string()); + false /*ignored*/, false /*ignored*/, 777000, 1, "Telegram", "Updates", string(), "42777", + std::move(profile_photo), nullptr, 0, string(), string(), string()); on_get_user(std::move(user), "get_user_force"); u = get_user(user_id); CHECK(u != nullptr && u->is_received); @@ -9786,8 +9793,8 @@ int32 ContactsManager::get_user_id_object(UserId user_id, const char *source) co td_api::make_object(td_api::make_object( user_id.get(), "", "", "", "", td_api::make_object(), get_profile_photo_object(td_->file_manager_.get(), nullptr), - get_link_state_object(LinkState::Unknown), get_link_state_object(LinkState::Unknown), false, "", - false, td_api::make_object(), ""))); + get_link_state_object(LinkState::Unknown), get_link_state_object(LinkState::Unknown), false, false, + "", false, td_api::make_object(), ""))); } return user_id.get(); } @@ -9813,8 +9820,8 @@ tl_object_ptr ContactsManager::get_user_object(UserId user_id, con return make_tl_object( user_id.get(), u->first_name, u->last_name, u->username, u->phone_number, get_user_status_object(user_id, u), get_profile_photo_object(td_->file_manager_.get(), &u->photo), get_link_state_object(u->outbound), - get_link_state_object(u->inbound), u->is_verified, u->restriction_reason, u->is_received, std::move(type), - u->language_code); + get_link_state_object(u->inbound), u->is_verified, u->is_support, u->restriction_reason, u->is_received, + std::move(type), u->language_code); } vector ContactsManager::get_user_ids_object(const vector &user_ids) const { diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index fba1d522c..8e2589743 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -129,7 +129,7 @@ class ContactsManager : public Actor { void on_get_contacts_link(tl_object_ptr &&link); void on_get_user(tl_object_ptr &&user, const char *source, bool is_me = false, - bool is_support = false); + bool expect_support = false); void on_get_users(vector> &&users, const char *source); void on_binlog_user_event(BinlogEvent &&event); @@ -473,6 +473,7 @@ class ContactsManager : public Actor { bool is_received = false; bool is_verified = false; + bool is_support = false; bool is_deleted = true; bool is_bot = true; bool can_join_groups = true; @@ -722,6 +723,7 @@ class ContactsManager : public Actor { static constexpr int32 USER_FLAG_IS_INACCESSIBLE = 1 << 20; static constexpr int32 USER_FLAG_NEED_LOCATION_BOT = 1 << 21; static constexpr int32 USER_FLAG_HAS_LANGUAGE_CODE = 1 << 22; + static constexpr int32 USER_FLAG_IS_SUPPORT = 1 << 23; static constexpr int32 USER_FULL_FLAG_IS_BLOCKED = 1 << 0; static constexpr int32 USER_FULL_FLAG_HAS_ABOUT = 1 << 1;