Add td_api::getCloseFriends.
This commit is contained in:
parent
a65af73b90
commit
fb57555f3d
@ -7509,7 +7509,7 @@ addContact contact:contact share_phone_number:Bool = Ok;
|
||||
//@description Adds new contacts or edits existing contacts by their phone numbers; contacts' user identifiers are ignored @contacts The list of contacts to import or edit; contacts' vCard are ignored and are not imported
|
||||
importContacts contacts:vector<contact> = ImportedContacts;
|
||||
|
||||
//@description Returns all user contacts
|
||||
//@description Returns all contacts of the user
|
||||
getContacts = Users;
|
||||
|
||||
//@description Searches for the specified query in the first names, last names and usernames of the known user contacts
|
||||
@ -7531,6 +7531,9 @@ changeImportedContacts contacts:vector<contact> = ImportedContacts;
|
||||
//@description Clears all imported contacts, contact list remains unchanged
|
||||
clearImportedContacts = Ok;
|
||||
|
||||
//@description Returns all close friends of the user
|
||||
getCloseFriends = Users;
|
||||
|
||||
//@description Changes a personal profile photo of a contact user @user_id User identifier @photo Profile photo to set; pass null to delete the photo; inputChatPhotoPrevious isn't supported in this function
|
||||
setUserPersonalProfilePhoto user_id:int53 photo:InputChatPhoto = Ok;
|
||||
|
||||
|
@ -6858,6 +6858,28 @@ std::pair<int32, vector<UserId>> ContactsManager::search_contacts(const string &
|
||||
return {narrow_cast<int32>(result.first), std::move(user_ids)};
|
||||
}
|
||||
|
||||
vector<UserId> ContactsManager::get_close_friends(Promise<Unit> &&promise) {
|
||||
if (!are_contacts_loaded_) {
|
||||
load_contacts(std::move(promise));
|
||||
return {};
|
||||
}
|
||||
reload_contacts(false);
|
||||
|
||||
auto result = contacts_hints_.search_empty(10000);
|
||||
|
||||
vector<UserId> user_ids;
|
||||
for (auto key : result.second) {
|
||||
UserId user_id(key);
|
||||
const User *u = get_user(user_id);
|
||||
if (u != nullptr && u->is_close_friend) {
|
||||
user_ids.push_back(user_id);
|
||||
}
|
||||
}
|
||||
|
||||
promise.set_value(Unit());
|
||||
return user_ids;
|
||||
}
|
||||
|
||||
UserId ContactsManager::search_user_by_phone_number(string phone_number, Promise<Unit> &&promise) {
|
||||
clean_phone_number(phone_number);
|
||||
if (phone_number.empty()) {
|
||||
|
@ -358,6 +358,8 @@ class ContactsManager final : public Actor {
|
||||
|
||||
void on_update_contacts_reset();
|
||||
|
||||
vector<UserId> get_close_friends(Promise<Unit> &&promise);
|
||||
|
||||
UserId search_user_by_phone_number(string phone_number, Promise<Unit> &&promise);
|
||||
|
||||
void on_resolved_phone_number(const string &phone_number, UserId user_id);
|
||||
|
@ -1889,6 +1889,22 @@ class ChangeImportedContactsRequest final : public RequestActor<> {
|
||||
}
|
||||
};
|
||||
|
||||
class GetCloseFriendsRequest final : public RequestActor<> {
|
||||
vector<UserId> user_ids_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
user_ids_ = td_->contacts_manager_->get_close_friends(std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_users_object(-1, user_ids_));
|
||||
}
|
||||
|
||||
public:
|
||||
GetCloseFriendsRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
||||
}
|
||||
};
|
||||
|
||||
class GetRecentInlineBotsRequest final : public RequestActor<> {
|
||||
vector<UserId> user_ids_;
|
||||
|
||||
@ -6976,6 +6992,11 @@ void Td::on_request(uint64 id, const td_api::clearImportedContacts &request) {
|
||||
contacts_manager_->clear_imported_contacts(std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getCloseFriends &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_NO_ARGS_REQUEST(GetCloseFriendsRequest);
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setUserPersonalProfilePhoto &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
|
@ -1125,6 +1125,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::clearImportedContacts &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getCloseFriends &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setUserPersonalProfilePhoto &request);
|
||||
|
||||
void on_request(uint64 id, td_api::suggestUserProfilePhoto &request);
|
||||
|
@ -2391,6 +2391,8 @@ class CliClient final : public Actor {
|
||||
} else {
|
||||
send_request(td_api::make_object<td_api::searchContacts>("", as_limit(args)));
|
||||
}
|
||||
} else if (op == "gcfr") {
|
||||
send_request(td_api::make_object<td_api::getCloseFriends>());
|
||||
} else if (op == "gul") {
|
||||
send_request(td_api::make_object<td_api::getUserLink>());
|
||||
} else if (op == "subt") {
|
||||
|
Loading…
Reference in New Issue
Block a user