Move get_user_link to AccountManager.
This commit is contained in:
parent
5f1b1f41fc
commit
be442ba977
@ -9,6 +9,7 @@
|
|||||||
#include "td/telegram/ContactsManager.h"
|
#include "td/telegram/ContactsManager.h"
|
||||||
#include "td/telegram/DeviceTokenManager.h"
|
#include "td/telegram/DeviceTokenManager.h"
|
||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
|
#include "td/telegram/LinkManager.h"
|
||||||
#include "td/telegram/net/NetQueryCreator.h"
|
#include "td/telegram/net/NetQueryCreator.h"
|
||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
#include "td/telegram/telegram_api.h"
|
#include "td/telegram/telegram_api.h"
|
||||||
@ -676,7 +677,24 @@ void AccountManager::disconnect_all_websites(Promise<Unit> &&promise) {
|
|||||||
td_->create_handler<ResetWebAuthorizationsQuery>(std::move(promise))->send();
|
td_->create_handler<ResetWebAuthorizationsQuery>(std::move(promise))->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::export_contact_token(Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
|
void AccountManager::get_user_link(Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
|
||||||
|
td_->contacts_manager_->get_me(
|
||||||
|
PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
promise.set_error(result.move_as_error());
|
||||||
|
} else {
|
||||||
|
send_closure(actor_id, &AccountManager::get_user_link_impl, std::move(promise));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountManager::get_user_link_impl(Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
|
||||||
|
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||||
|
auto username = td_->contacts_manager_->get_user_first_username(td_->contacts_manager_->get_my_id());
|
||||||
|
if (!username.empty()) {
|
||||||
|
return promise.set_value(
|
||||||
|
td_api::make_object<td_api::userLink>(LinkManager::get_public_dialog_link(username, true), 0));
|
||||||
|
}
|
||||||
td_->create_handler<ExportContactTokenQuery>(std::move(promise))->send();
|
td_->create_handler<ExportContactTokenQuery>(std::move(promise))->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class AccountManager final : public Actor {
|
|||||||
|
|
||||||
void disconnect_all_websites(Promise<Unit> &&promise);
|
void disconnect_all_websites(Promise<Unit> &&promise);
|
||||||
|
|
||||||
void export_contact_token(Promise<td_api::object_ptr<td_api::userLink>> &&promise);
|
void get_user_link(Promise<td_api::object_ptr<td_api::userLink>> &&promise);
|
||||||
|
|
||||||
void import_contact_token(const string &token, Promise<td_api::object_ptr<td_api::user>> &&promise);
|
void import_contact_token(const string &token, Promise<td_api::object_ptr<td_api::user>> &&promise);
|
||||||
|
|
||||||
@ -60,6 +60,8 @@ class AccountManager final : public Actor {
|
|||||||
private:
|
private:
|
||||||
void tear_down() final;
|
void tear_down() final;
|
||||||
|
|
||||||
|
void get_user_link_impl(Promise<td_api::object_ptr<td_api::userLink>> &&promise);
|
||||||
|
|
||||||
Td *td_;
|
Td *td_;
|
||||||
ActorShared<> parent_;
|
ActorShared<> parent_;
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
//
|
//
|
||||||
#include "td/telegram/ContactsManager.h"
|
#include "td/telegram/ContactsManager.h"
|
||||||
|
|
||||||
#include "td/telegram/AccountManager.h"
|
|
||||||
#include "td/telegram/AnimationsManager.h"
|
#include "td/telegram/AnimationsManager.h"
|
||||||
#include "td/telegram/AuthManager.h"
|
#include "td/telegram/AuthManager.h"
|
||||||
#include "td/telegram/BlockListId.h"
|
#include "td/telegram/BlockListId.h"
|
||||||
@ -16838,27 +16837,6 @@ void ContactsManager::reload_dialog_info(DialogId dialog_id, Promise<Unit> &&pro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::get_user_link(Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
|
|
||||||
get_me(
|
|
||||||
PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](Result<Unit> &&result) mutable {
|
|
||||||
if (result.is_error()) {
|
|
||||||
promise.set_error(result.move_as_error());
|
|
||||||
} else {
|
|
||||||
send_closure(actor_id, &ContactsManager::get_user_link_impl, std::move(promise));
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContactsManager::get_user_link_impl(Promise<td_api::object_ptr<td_api::userLink>> &&promise) {
|
|
||||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
|
||||||
const auto *u = get_user(get_my_id());
|
|
||||||
if (u != nullptr && u->usernames.has_first_username()) {
|
|
||||||
return promise.set_value(td_api::make_object<td_api::userLink>(
|
|
||||||
LinkManager::get_public_dialog_link(u->usernames.get_first_username(), true), 0));
|
|
||||||
}
|
|
||||||
td_->account_manager_->export_contact_token(std::move(promise));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContactsManager::send_get_me_query(Td *td, Promise<Unit> &&promise) {
|
void ContactsManager::send_get_me_query(Td *td, Promise<Unit> &&promise) {
|
||||||
vector<tl_object_ptr<telegram_api::InputUser>> users;
|
vector<tl_object_ptr<telegram_api::InputUser>> users;
|
||||||
users.push_back(make_tl_object<telegram_api::inputUserSelf>());
|
users.push_back(make_tl_object<telegram_api::inputUserSelf>());
|
||||||
|
@ -583,8 +583,6 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
void reload_dialog_info(DialogId dialog_id, Promise<Unit> &&promise);
|
void reload_dialog_info(DialogId dialog_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void get_user_link(Promise<td_api::object_ptr<td_api::userLink>> &&promise);
|
|
||||||
|
|
||||||
static void send_get_me_query(Td *td, Promise<Unit> &&promise);
|
static void send_get_me_query(Td *td, Promise<Unit> &&promise);
|
||||||
UserId get_me(Promise<Unit> &&promise);
|
UserId get_me(Promise<Unit> &&promise);
|
||||||
bool get_user(UserId user_id, int left_tries, Promise<Unit> &&promise);
|
bool get_user(UserId user_id, int left_tries, Promise<Unit> &&promise);
|
||||||
@ -1405,8 +1403,6 @@ class ContactsManager final : public Actor {
|
|||||||
string get_channel_search_text(ChannelId channel_id) const;
|
string get_channel_search_text(ChannelId channel_id) const;
|
||||||
static string get_channel_search_text(const Channel *c);
|
static string get_channel_search_text(const Channel *c);
|
||||||
|
|
||||||
void get_user_link_impl(Promise<td_api::object_ptr<td_api::userLink>> &&promise);
|
|
||||||
|
|
||||||
void set_my_id(UserId my_id);
|
void set_my_id(UserId my_id);
|
||||||
|
|
||||||
static bool is_allowed_username(const string &username);
|
static bool is_allowed_username(const string &username);
|
||||||
|
@ -4625,7 +4625,7 @@ void Td::on_request(uint64 id, td_api::resendChangePhoneNumberCode &request) {
|
|||||||
void Td::on_request(uint64 id, const td_api::getUserLink &request) {
|
void Td::on_request(uint64 id, const td_api::getUserLink &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_REQUEST_PROMISE();
|
CREATE_REQUEST_PROMISE();
|
||||||
contacts_manager_->get_user_link(std::move(promise));
|
account_manager_->get_user_link(std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::searchUserByToken &request) {
|
void Td::on_request(uint64 id, td_api::searchUserByToken &request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user