Add user.has_anonymous_phone_number.

This commit is contained in:
levlam 2022-11-30 12:43:54 +03:00
parent 7e88119c1f
commit b0e22e15e2
3 changed files with 23 additions and 4 deletions

View File

@ -512,6 +512,7 @@ usernames active_usernames:vector<string> disabled_usernames:vector<string> edit
//@is_verified True, if the user is verified
//@is_premium True, if the user is a Telegram Premium user
//@is_support True, if the user is Telegram support account
//@has_anonymous_phone_number True, if the user's phone number was bought on Fragment and isn't tied to a SIM card
//@restriction_reason If non-empty, it contains a human-readable description of the reason why access to this user must be restricted
//@is_scam True, if many users reported this user as a scam
//@is_fake True, if many users reported this user as a fake account
@ -519,7 +520,7 @@ usernames active_usernames:vector<string> disabled_usernames:vector<string> edit
//@type Type of the user
//@language_code IETF language tag of the user's language; only available to bots
//@added_to_attachment_menu True, if the user added the current bot to attachment menu; only available to bots
user id:int53 first_name:string last_name:string usernames:usernames phone_number:string status:UserStatus profile_photo:profilePhoto emoji_status:emojiStatus is_contact:Bool is_mutual_contact:Bool is_verified:Bool is_premium:Bool is_support:Bool restriction_reason:string is_scam:Bool is_fake:Bool have_access:Bool type:UserType language_code:string added_to_attachment_menu:Bool = User;
user id:int53 first_name:string last_name:string usernames:usernames phone_number:string status:UserStatus profile_photo:profilePhoto emoji_status:emojiStatus is_contact:Bool is_mutual_contact:Bool is_verified:Bool is_premium:Bool is_support:Bool has_anonymous_phone_number:Bool restriction_reason:string is_scam:Bool is_fake:Bool have_access:Bool type:UserType language_code:string added_to_attachment_menu:Bool = User;
//@description Contains information about a bot

View File

@ -11012,6 +11012,7 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
if (!u->phone_number.empty() && !td_->auth_manager_->is_bot()) {
resolved_phone_numbers_[u->phone_number] = user_id;
}
u->is_fragment_phone_number = is_fragment_phone_number(u->phone_number);
u->is_phone_number_changed = false;
}
if (u->is_status_changed && user_id != get_my_id()) {
@ -16890,6 +16891,19 @@ void ContactsManager::on_update_channel_administrator_count(ChannelId channel_id
}
}
bool ContactsManager::is_fragment_phone_number(string phone_number) const {
if (phone_number.empty()) {
return false;
}
clean_phone_number(phone_number);
for (auto &prefix : fragment_prefixes_) {
if (begins_with(phone_number, prefix)) {
return true;
}
}
return false;
}
void ContactsManager::on_update_fragment_prefixes() {
if (G()->close_flag()) {
return;
@ -17572,7 +17586,8 @@ td_api::object_ptr<td_api::UserStatus> ContactsManager::get_user_status_object(U
td_api::object_ptr<td_api::updateUser> ContactsManager::get_update_unknown_user_object(UserId user_id) {
return td_api::make_object<td_api::updateUser>(td_api::make_object<td_api::user>(
user_id.get(), "", "", nullptr, "", td_api::make_object<td_api::userStatusEmpty>(), nullptr, nullptr, false,
false, false, false, false, "", false, false, false, td_api::make_object<td_api::userTypeUnknown>(), "", false));
false, false, false, false, false, "", false, false, false, td_api::make_object<td_api::userTypeUnknown>(), "",
false));
}
int64 ContactsManager::get_user_id_object(UserId user_id, const char *source) const {
@ -17608,8 +17623,8 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, con
user_id.get(), u->first_name, u->last_name, u->usernames.get_usernames_object(), u->phone_number,
get_user_status_object(user_id, u), get_profile_photo_object(td_->file_manager_.get(), u->photo),
std::move(emoji_status), u->is_contact, u->is_mutual_contact, u->is_verified, u->is_premium, u->is_support,
get_restriction_reason_description(u->restriction_reasons), u->is_scam, u->is_fake, u->is_received,
std::move(type), u->language_code, u->attach_menu_enabled);
u->is_fragment_phone_number, get_restriction_reason_description(u->restriction_reasons), u->is_scam, u->is_fake,
u->is_received, std::move(type), u->language_code, u->attach_menu_enabled);
}
vector<int64> ContactsManager::get_user_ids_object(const vector<UserId> &user_ids, const char *source) const {

View File

@ -730,6 +730,7 @@ class ContactsManager final : public Actor {
bool need_apply_min_photo = false;
bool can_be_added_to_attach_menu = false;
bool attach_menu_enabled = false;
bool is_fragment_phone_number = false;
bool is_photo_inited = false;
@ -1504,6 +1505,8 @@ class ContactsManager final : public Actor {
bool is_user_contact(const User *u, UserId user_id, bool is_mutual) const;
bool is_fragment_phone_number(string phone_number) const;
int32 get_user_was_online(const User *u, UserId user_id) const;
int64 get_contacts_hash();