Add td_api::getSupportName.

This commit is contained in:
levlam 2023-03-22 13:54:04 +03:00
parent b5df19ae34
commit d3ef57e961
6 changed files with 51 additions and 0 deletions

View File

@ -8296,6 +8296,9 @@ getUserSupportInfo user_id:int53 = UserSupportInfo;
//@description Sets support information for the given user; for Telegram support only @user_id User identifier @message New information message //@description Sets support information for the given user; for Telegram support only @user_id User identifier @message New information message
setUserSupportInfo user_id:int53 message:formattedText = UserSupportInfo; setUserSupportInfo user_id:int53 message:formattedText = UserSupportInfo;
//@description Returns localized name of the Telegram support user; for Telegram support only
getSupportName = Text;
//@description Does nothing; for testing only. This is an offline method. Can be called before authorization //@description Does nothing; for testing only. This is an offline method. Can be called before authorization
testCallEmpty = Ok; testCallEmpty = Ok;

View File

@ -98,6 +98,31 @@ class EditUserInfoQuery final : public Td::ResultHandler {
} }
}; };
class GetSupportNameQuery final : public Td::ResultHandler {
Promise<string> promise_;
public:
explicit GetSupportNameQuery(Promise<string> &&promise) : promise_(std::move(promise)) {
}
void send() {
send_query(G()->net_query_creator().create(telegram_api::help_getSupportName()));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_getSupportName>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
promise_.set_value(std::move(result_ptr.ok_ref()->name_));
}
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
void get_user_info(Td *td, UserId user_id, Promise<td_api::object_ptr<td_api::userSupportInfo>> &&promise) { void get_user_info(Td *td, UserId user_id, Promise<td_api::object_ptr<td_api::userSupportInfo>> &&promise) {
td->create_handler<GetUserInfoQuery>(std::move(promise))->send(user_id); td->create_handler<GetUserInfoQuery>(std::move(promise))->send(user_id);
} }
@ -110,4 +135,8 @@ void set_user_info(Td *td, UserId user_id, td_api::object_ptr<td_api::formattedT
td->create_handler<EditUserInfoQuery>(std::move(promise))->send(user_id, std::move(formatted_text)); td->create_handler<EditUserInfoQuery>(std::move(promise))->send(user_id, std::move(formatted_text));
} }
void get_support_name(Td *td, Promise<string> &&promise) {
td->create_handler<GetSupportNameQuery>(std::move(promise))->send();
}
} // namespace td } // namespace td

View File

@ -21,4 +21,6 @@ void get_user_info(Td *td, UserId user_id, Promise<td_api::object_ptr<td_api::us
void set_user_info(Td *td, UserId user_id, td_api::object_ptr<td_api::formattedText> &&message, void set_user_info(Td *td, UserId user_id, td_api::object_ptr<td_api::formattedText> &&message,
Promise<td_api::object_ptr<td_api::userSupportInfo>> &&promise); Promise<td_api::object_ptr<td_api::userSupportInfo>> &&promise);
void get_support_name(Td *td, Promise<string> &&promise);
} // namespace td } // namespace td

View File

@ -8462,6 +8462,19 @@ void Td::on_request(uint64 id, td_api::setUserSupportInfo &request) {
set_user_info(this, UserId(request.user_id_), std::move(request.message_), std::move(promise)); set_user_info(this, UserId(request.user_id_), std::move(request.message_), std::move(promise));
} }
void Td::on_request(uint64 id, const td_api::getSupportName &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
if (result.is_error()) {
promise.set_error(result.move_as_error());
} else {
promise.set_value(make_tl_object<td_api::text>(result.move_as_ok()));
}
});
get_support_name(this, std::move(query_promise));
}
void Td::on_request(uint64 id, const td_api::getTextEntities &request) { void Td::on_request(uint64 id, const td_api::getTextEntities &request) {
UNREACHABLE(); UNREACHABLE();
} }

View File

@ -1507,6 +1507,8 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::setUserSupportInfo &request); void on_request(uint64 id, td_api::setUserSupportInfo &request);
void on_request(uint64 id, const td_api::getSupportName &request);
void on_request(uint64 id, const td_api::getTextEntities &request); void on_request(uint64 id, const td_api::getTextEntities &request);
void on_request(uint64 id, const td_api::parseTextEntities &request); void on_request(uint64 id, const td_api::parseTextEntities &request);

View File

@ -5297,6 +5297,8 @@ class CliClient final : public Actor {
string text; string text;
get_args(args, user_id, text); get_args(args, user_id, text);
send_request(td_api::make_object<td_api::setUserSupportInfo>(user_id, as_formatted_text(text))); send_request(td_api::make_object<td_api::setUserSupportInfo>(user_id, as_formatted_text(text)));
} else if (op == "gsn") {
send_request(td_api::make_object<td_api::getSupportName>());
} else if (op == "touch") { } else if (op == "touch") {
auto r_fd = FileFd::open(args, FileFd::Read | FileFd::Write); auto r_fd = FileFd::open(args, FileFd::Read | FileFd::Write);
if (r_fd.is_error()) { if (r_fd.is_error()) {