Implement getSupportUser with request promise instead of RequestActor.
This commit is contained in:
parent
1995cbe6bc
commit
c17520fdbc
@ -16700,10 +16700,9 @@ tl_object_ptr<td_api::chatInviteLinkInfo> ContactsManager::get_chat_invite_link_
|
||||
creates_join_request, is_public);
|
||||
}
|
||||
|
||||
UserId ContactsManager::get_support_user(Promise<Unit> &&promise) {
|
||||
void ContactsManager::get_support_user(Promise<td_api::object_ptr<td_api::user>> &&promise) {
|
||||
if (support_user_id_.is_valid()) {
|
||||
promise.set_value(Unit());
|
||||
return support_user_id_;
|
||||
return promise.set_value(get_user_object(support_user_id_));
|
||||
}
|
||||
|
||||
auto query_promise = PromiseCreator::lambda(
|
||||
@ -16715,10 +16714,9 @@ UserId ContactsManager::get_support_user(Promise<Unit> &&promise) {
|
||||
}
|
||||
});
|
||||
td_->create_handler<GetSupportUserQuery>(std::move(query_promise))->send();
|
||||
return UserId();
|
||||
}
|
||||
|
||||
void ContactsManager::on_get_support_user(UserId user_id, Promise<Unit> &&promise) {
|
||||
void ContactsManager::on_get_support_user(UserId user_id, Promise<td_api::object_ptr<td_api::user>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
|
||||
const User *u = get_user(user_id);
|
||||
@ -16730,7 +16728,7 @@ void ContactsManager::on_get_support_user(UserId user_id, Promise<Unit> &&promis
|
||||
}
|
||||
|
||||
support_user_id_ = user_id;
|
||||
promise.set_value(Unit());
|
||||
promise.set_value(get_user_object(user_id, u));
|
||||
}
|
||||
|
||||
void ContactsManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
|
||||
|
@ -598,7 +598,7 @@ class ContactsManager final : public Actor {
|
||||
|
||||
tl_object_ptr<td_api::chatInviteLinkInfo> get_chat_invite_link_info_object(const string &invite_link);
|
||||
|
||||
UserId get_support_user(Promise<Unit> &&promise);
|
||||
void get_support_user(Promise<td_api::object_ptr<td_api::user>> &&promise);
|
||||
|
||||
void repair_chat_participants(ChatId chat_id);
|
||||
|
||||
@ -1631,7 +1631,7 @@ class ContactsManager final : public Actor {
|
||||
void send_load_async_graph_query(DcId dc_id, string token, int64 x,
|
||||
Promise<td_api::object_ptr<td_api::StatisticalGraph>> &&promise);
|
||||
|
||||
void on_get_support_user(UserId user_id, Promise<Unit> &&promise);
|
||||
void on_get_support_user(UserId user_id, Promise<td_api::object_ptr<td_api::user>> &&promise);
|
||||
|
||||
static void on_user_online_timeout_callback(void *contacts_manager_ptr, int64 user_id_long);
|
||||
|
||||
|
@ -2675,22 +2675,6 @@ class GetInlineQueryResultsRequest final : public RequestOnceActor {
|
||||
}
|
||||
};
|
||||
|
||||
class GetSupportUserRequest final : public RequestActor<> {
|
||||
UserId user_id_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
user_id_ = td_->contacts_manager_->get_support_user(std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(td_->contacts_manager_->get_user_object(user_id_));
|
||||
}
|
||||
|
||||
public:
|
||||
GetSupportUserRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
||||
}
|
||||
};
|
||||
|
||||
class SearchBackgroundRequest final : public RequestActor<> {
|
||||
string name_;
|
||||
|
||||
@ -7721,7 +7705,8 @@ void Td::on_request(uint64 id, td_api::checkPhoneNumberConfirmationCode &request
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getSupportUser &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_NO_ARGS_REQUEST(GetSupportUserRequest);
|
||||
CREATE_REQUEST_PROMISE();
|
||||
contacts_manager_->get_support_user(std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getBackgrounds &request) {
|
||||
|
Loading…
Reference in New Issue
Block a user