Add user.is_support flag.

GitOrigin-RevId: 6c1774d309eefdb20e75e2b01e07a4738efcde81
This commit is contained in:
levlam 2019-03-01 05:35:01 +03:00
parent f8cc501d7a
commit f1419395df
6 changed files with 28 additions and 17 deletions

View File

@ -291,10 +291,12 @@ botInfo description:string commands:vector<botCommand> = 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 //@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 //@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) //-{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 //@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 //@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 //@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

Binary file not shown.

View File

@ -92,7 +92,7 @@ fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileL
fileLocation#91d11eb dc_id:int volume_id:long local_id:int secret:long file_reference:bytes = FileLocation; fileLocation#91d11eb dc_id:int volume_id:long local_id:int secret:long file_reference:bytes = FileLocation;
userEmpty#200250ba id:int = User; userEmpty#200250ba id:int = User;
user#2e13f4c3 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?string bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; user#2e13f4c3 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?string bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User;
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
userProfilePhoto#d559d8c8 photo_id:long photo_small:FileLocation photo_big:FileLocation = UserProfilePhoto; userProfilePhoto#d559d8c8 photo_id:long photo_small:FileLocation photo_big:FileLocation = UserProfilePhoto;

Binary file not shown.

View File

@ -2473,6 +2473,7 @@ void ContactsManager::User::store(StorerT &storer) const {
STORE_FLAG(is_restricted); STORE_FLAG(is_restricted);
STORE_FLAG(has_language_code); STORE_FLAG(has_language_code);
STORE_FLAG(have_access_hash); STORE_FLAG(have_access_hash);
STORE_FLAG(is_support);
END_STORE_FLAGS(); END_STORE_FLAGS();
store(first_name, storer); store(first_name, storer);
if (has_last_name) { if (has_last_name) {
@ -2529,6 +2530,7 @@ void ContactsManager::User::parse(ParserT &parser) {
PARSE_FLAG(is_restricted); PARSE_FLAG(is_restricted);
PARSE_FLAG(has_language_code); PARSE_FLAG(has_language_code);
PARSE_FLAG(have_access_hash); PARSE_FLAG(have_access_hash);
PARSE_FLAG(is_support);
END_PARSE_FLAGS(); END_PARSE_FLAGS();
parse(first_name, parser); parse(first_name, parser);
if (has_last_name) { if (has_last_name) {
@ -4994,7 +4996,7 @@ ChannelId ContactsManager::get_channel_id(const tl_object_ptr<telegram_api::Chat
} }
void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr, const char *source, bool is_me, void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr, const char *source, bool is_me,
bool is_support) { bool expect_support) {
LOG(DEBUG) << "Receive from " << source << ' ' << to_string(user_ptr); LOG(DEBUG) << "Receive from " << source << ' ' << to_string(user_ptr);
int32 constructor_id = user_ptr->get_id(); int32 constructor_id = user_ptr->get_id();
if (constructor_id == telegram_api::userEmpty::ID) { if (constructor_id == telegram_api::userEmpty::ID) {
@ -5044,7 +5046,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
*/ */
} }
if (is_support) { if (expect_support) {
support_user_id_ = user_id; support_user_id_ = user_id;
} }
@ -5088,6 +5090,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
} }
bool is_verified = (flags & USER_FLAG_IS_VERIFIED) != 0; 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 is_deleted = (flags & USER_FLAG_IS_DELETED) != 0;
bool can_join_groups = (flags & USER_FLAG_IS_PRIVATE_BOT) == 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; 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<telegram_api::User> &&user_ptr,
bool need_location_bot = (flags & USER_FLAG_NEED_LOCATION_BOT) != 0; bool need_location_bot = (flags & USER_FLAG_NEED_LOCATION_BOT) != 0;
bool has_bot_info_version = (flags & USER_FLAG_HAS_BOT_INFO_VERSION) != 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) LOG_IF(ERROR, !can_join_groups && !is_bot)
<< "Receive not bot " << user_id << " which can't join groups from " << source; << "Receive not bot " << user_id << " which can't join groups from " << source;
LOG_IF(ERROR, can_read_all_group_messages && !is_bot) LOG_IF(ERROR, can_read_all_group_messages && !is_bot)
@ -5115,6 +5119,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
if (is_deleted) { if (is_deleted) {
// just in case // just in case
is_verified = false; is_verified = false;
is_support = false;
is_bot = false; is_bot = false;
can_join_groups = false; can_join_groups = false;
can_read_all_group_messages = false; can_read_all_group_messages = false;
@ -5128,14 +5133,15 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
<< "Receive not bot " << user_id << " which has bot info version from " << source; << "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; 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 || if (is_verified != u->is_verified || is_support != u->is_support || is_bot != u->is_bot ||
can_read_all_group_messages != u->can_read_all_group_messages || restriction_reason != u->restriction_reason || can_join_groups != u->can_join_groups || can_read_all_group_messages != u->can_read_all_group_messages ||
is_inline_bot != u->is_inline_bot || inline_query_placeholder != u->inline_query_placeholder || restriction_reason != u->restriction_reason || is_inline_bot != u->is_inline_bot ||
need_location_bot != u->need_location_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) 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 " << "User.is_bot has changed for " << user_id << "/" << u->username << " from " << source << " from "
<< u->is_bot << " to " << is_bot; << u->is_bot << " to " << is_bot;
u->is_verified = is_verified; u->is_verified = is_verified;
u->is_support = is_support;
u->is_bot = is_bot; u->is_bot = is_bot;
u->can_join_groups = can_join_groups; u->can_join_groups = can_join_groups;
u->can_read_all_group_messages = can_read_all_group_messages; 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); auto u = get_user_force_impl(user_id);
if (user_id == UserId(777000) && (u == nullptr || !u->is_received)) { if (user_id == UserId(777000) && (u == nullptr || !u->is_received)) {
int32 flags = telegram_api::user::ACCESS_HASH_MASK | telegram_api::user::FIRST_NAME_MASK | 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<telegram_api::userProfilePhoto>( auto profile_photo = telegram_api::make_object<telegram_api::userProfilePhoto>(
3337190045231018, 3337190045231018,
telegram_api::make_object<telegram_api::fileLocation>(1, 702229962, 26779, 5859320227133863146, BufferSlice()), telegram_api::make_object<telegram_api::fileLocation>(1, 702229962, 26779, 5859320227133863146, BufferSlice()),
@ -5416,8 +5423,8 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
auto user = telegram_api::make_object<telegram_api::user>( auto user = telegram_api::make_object<telegram_api::user>(
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
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, false /*ignored*/, false /*ignored*/, 777000, 1, "Telegram", "Updates", string(), "42777",
string(), string(), string()); std::move(profile_photo), nullptr, 0, string(), string(), string());
on_get_user(std::move(user), "get_user_force"); on_get_user(std::move(user), "get_user_force");
u = get_user(user_id); u = get_user(user_id);
CHECK(u != nullptr && u->is_received); 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::updateUser>(td_api::make_object<td_api::user>( td_api::make_object<td_api::updateUser>(td_api::make_object<td_api::user>(
user_id.get(), "", "", "", "", td_api::make_object<td_api::userStatusEmpty>(), user_id.get(), "", "", "", "", td_api::make_object<td_api::userStatusEmpty>(),
get_profile_photo_object(td_->file_manager_.get(), nullptr), get_profile_photo_object(td_->file_manager_.get(), nullptr),
get_link_state_object(LinkState::Unknown), get_link_state_object(LinkState::Unknown), false, "", get_link_state_object(LinkState::Unknown), get_link_state_object(LinkState::Unknown), false, false,
false, td_api::make_object<td_api::userTypeUnknown>(), ""))); "", false, td_api::make_object<td_api::userTypeUnknown>(), "")));
} }
return user_id.get(); return user_id.get();
} }
@ -9813,8 +9820,8 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, con
return make_tl_object<td_api::user>( return make_tl_object<td_api::user>(
user_id.get(), u->first_name, u->last_name, u->username, u->phone_number, get_user_status_object(user_id, u), 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_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), get_link_state_object(u->inbound), u->is_verified, u->is_support, u->restriction_reason, u->is_received,
u->language_code); std::move(type), u->language_code);
} }
vector<int32> ContactsManager::get_user_ids_object(const vector<UserId> &user_ids) const { vector<int32> ContactsManager::get_user_ids_object(const vector<UserId> &user_ids) const {

View File

@ -129,7 +129,7 @@ class ContactsManager : public Actor {
void on_get_contacts_link(tl_object_ptr<telegram_api::contacts_link> &&link); void on_get_contacts_link(tl_object_ptr<telegram_api::contacts_link> &&link);
void on_get_user(tl_object_ptr<telegram_api::User> &&user, const char *source, bool is_me = false, void on_get_user(tl_object_ptr<telegram_api::User> &&user, const char *source, bool is_me = false,
bool is_support = false); bool expect_support = false);
void on_get_users(vector<tl_object_ptr<telegram_api::User>> &&users, const char *source); void on_get_users(vector<tl_object_ptr<telegram_api::User>> &&users, const char *source);
void on_binlog_user_event(BinlogEvent &&event); void on_binlog_user_event(BinlogEvent &&event);
@ -473,6 +473,7 @@ class ContactsManager : public Actor {
bool is_received = false; bool is_received = false;
bool is_verified = false; bool is_verified = false;
bool is_support = false;
bool is_deleted = true; bool is_deleted = true;
bool is_bot = true; bool is_bot = true;
bool can_join_groups = 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_IS_INACCESSIBLE = 1 << 20;
static constexpr int32 USER_FLAG_NEED_LOCATION_BOT = 1 << 21; 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_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_IS_BLOCKED = 1 << 0;
static constexpr int32 USER_FULL_FLAG_HAS_ABOUT = 1 << 1; static constexpr int32 USER_FULL_FLAG_HAS_ABOUT = 1 << 1;