Add td_api::setCloseFriends.
This commit is contained in:
parent
86946c6b1e
commit
161cc91acf
@ -7531,7 +7531,10 @@ changeImportedContacts contacts:vector<contact> = ImportedContacts;
|
|||||||
//@description Clears all imported contacts, contact list remains unchanged
|
//@description Clears all imported contacts, contact list remains unchanged
|
||||||
clearImportedContacts = Ok;
|
clearImportedContacts = Ok;
|
||||||
|
|
||||||
//@description Returns all close friends of the user
|
//@description Changes the list of close friends of the current user @user_ids User identifiers of close friends; the users must be contacts of the current user
|
||||||
|
setCloseFriends user_ids:vector<int53> = Ok;
|
||||||
|
|
||||||
|
//@description Returns all close friends of the current user
|
||||||
getCloseFriends = Users;
|
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
|
//@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
|
||||||
|
@ -196,6 +196,32 @@ class AddContactQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class EditCloseFriendsQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit EditCloseFriendsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(const vector<UserId> &user_ids) {
|
||||||
|
send_query(
|
||||||
|
G()->net_query_creator().create(telegram_api::contacts_editCloseFriends(UserId::get_input_user_ids(user_ids))));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::contacts_editCloseFriends>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class ResolvePhoneQuery final : public Td::ResultHandler {
|
class ResolvePhoneQuery final : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
string phone_number_;
|
string phone_number_;
|
||||||
@ -6880,6 +6906,16 @@ vector<UserId> ContactsManager::get_close_friends(Promise<Unit> &&promise) {
|
|||||||
return user_ids;
|
return user_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::set_close_friends(const vector<UserId> &user_ids, Promise<Unit> &&promise) {
|
||||||
|
for (auto &user_id : user_ids) {
|
||||||
|
if (!have_user(user_id)) {
|
||||||
|
return promise.set_error(Status::Error(400, "User not found"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
td_->create_handler<EditCloseFriendsQuery>(std::move(promise))->send(user_ids);
|
||||||
|
}
|
||||||
|
|
||||||
UserId ContactsManager::search_user_by_phone_number(string phone_number, Promise<Unit> &&promise) {
|
UserId ContactsManager::search_user_by_phone_number(string phone_number, Promise<Unit> &&promise) {
|
||||||
clean_phone_number(phone_number);
|
clean_phone_number(phone_number);
|
||||||
if (phone_number.empty()) {
|
if (phone_number.empty()) {
|
||||||
|
@ -360,6 +360,8 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
vector<UserId> get_close_friends(Promise<Unit> &&promise);
|
vector<UserId> get_close_friends(Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void set_close_friends(const vector<UserId> &user_ids, Promise<Unit> &&promise);
|
||||||
|
|
||||||
UserId search_user_by_phone_number(string phone_number, 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);
|
void on_resolved_phone_number(const string &phone_number, UserId user_id);
|
||||||
|
@ -6997,6 +6997,12 @@ void Td::on_request(uint64 id, const td_api::getCloseFriends &request) {
|
|||||||
CREATE_NO_ARGS_REQUEST(GetCloseFriendsRequest);
|
CREATE_NO_ARGS_REQUEST(GetCloseFriendsRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::setCloseFriends &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
contacts_manager_->set_close_friends(UserId::get_user_ids(request.user_ids_), std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::setUserPersonalProfilePhoto &request) {
|
void Td::on_request(uint64 id, td_api::setUserPersonalProfilePhoto &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
@ -1127,6 +1127,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::getCloseFriends &request);
|
void on_request(uint64 id, const td_api::getCloseFriends &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::setCloseFriends &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::setUserPersonalProfilePhoto &request);
|
void on_request(uint64 id, td_api::setUserPersonalProfilePhoto &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::suggestUserProfilePhoto &request);
|
void on_request(uint64 id, td_api::suggestUserProfilePhoto &request);
|
||||||
|
@ -2393,6 +2393,8 @@ class CliClient final : public Actor {
|
|||||||
}
|
}
|
||||||
} else if (op == "gcfr") {
|
} else if (op == "gcfr") {
|
||||||
send_request(td_api::make_object<td_api::getCloseFriends>());
|
send_request(td_api::make_object<td_api::getCloseFriends>());
|
||||||
|
} else if (op == "scfr") {
|
||||||
|
send_request(td_api::make_object<td_api::setCloseFriends>(as_user_ids(args)));
|
||||||
} else if (op == "gul") {
|
} else if (op == "gul") {
|
||||||
send_request(td_api::make_object<td_api::getUserLink>());
|
send_request(td_api::make_object<td_api::getUserLink>());
|
||||||
} else if (op == "subt") {
|
} else if (op == "subt") {
|
||||||
|
Loading…
Reference in New Issue
Block a user