Add setUserSupportInfo.
This commit is contained in:
parent
f0a89c3dbe
commit
bbac7baed0
@ -6591,6 +6591,9 @@ addLogMessage verbosity_level:int32 text:string = Ok;
|
|||||||
//@description Returns support information for the given user; for Telegram support only @user_id User identifier
|
//@description Returns support information for the given user; for Telegram support only @user_id User identifier
|
||||||
getUserSupportInfo user_id:int53 = UserSupportInfo;
|
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
|
||||||
|
setUserSupportInfo user_id:int53 message:formattedText = UserSupportInfo;
|
||||||
|
|
||||||
|
|
||||||
//@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;
|
||||||
|
@ -4300,7 +4300,7 @@ Result<FormattedText> get_formatted_text(const Td *td, DialogId dialog_id,
|
|||||||
return FormattedText();
|
return FormattedText();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status::Error(400, "Text can't be empty");
|
return Status::Error(400, "Text must be non-empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
TRY_RESULT(entities, get_message_entities(td->contacts_manager_.get(), std::move(text->entities_)));
|
TRY_RESULT(entities, get_message_entities(td->contacts_manager_.get(), std::move(text->entities_)));
|
||||||
|
@ -64,8 +64,49 @@ class GetUserInfoQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class EditUserInfoQuery final : public Td::ResultHandler {
|
||||||
|
Promise<td_api::object_ptr<td_api::userSupportInfo>> promise_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit EditUserInfoQuery(Promise<td_api::object_ptr<td_api::userSupportInfo>> &&promise)
|
||||||
|
: promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(UserId user_id, FormattedText &&formatted_text) {
|
||||||
|
auto r_input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||||
|
if (r_input_user.is_error()) {
|
||||||
|
return on_error(r_input_user.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
send_query(G()->net_query_creator().create(telegram_api::help_editUserInfo(
|
||||||
|
r_input_user.move_as_ok(), formatted_text.text,
|
||||||
|
get_input_message_entities(td_->contacts_manager_.get(), &formatted_text, "EditUserInfoQuery"))));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::help_editUserInfo>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
promise_.set_value(get_user_support_info_object(td_, result_ptr.move_as_ok()));
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
TRY_RESULT_PROMISE(
|
||||||
|
promise, formatted_text,
|
||||||
|
get_formatted_text(td, DialogId(td->contacts_manager_->get_my_id()), std::move(message), false, true, true, false));
|
||||||
|
td->create_handler<EditUserInfoQuery>(std::move(promise))->send(user_id, std::move(formatted_text));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -18,4 +18,7 @@ class Td;
|
|||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -7999,6 +7999,12 @@ void Td::on_request(uint64 id, const td_api::getUserSupportInfo &request) {
|
|||||||
get_user_info(this, UserId(request.user_id_), std::move(promise));
|
get_user_info(this, UserId(request.user_id_), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, td_api::setUserSupportInfo &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_REQUEST_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::getTextEntities &request) {
|
void Td::on_request(uint64 id, const td_api::getTextEntities &request) {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
@ -1349,6 +1349,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::getUserSupportInfo &request);
|
void on_request(uint64 id, const td_api::getUserSupportInfo &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, td_api::setUserSupportInfo &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);
|
||||||
|
@ -4824,6 +4824,11 @@ class CliClient final : public Actor {
|
|||||||
UserId user_id;
|
UserId user_id;
|
||||||
get_args(args, user_id);
|
get_args(args, user_id);
|
||||||
send_request(td_api::make_object<td_api::getUserSupportInfo>(user_id));
|
send_request(td_api::make_object<td_api::getUserSupportInfo>(user_id));
|
||||||
|
} else if (op == "susi") {
|
||||||
|
UserId user_id;
|
||||||
|
string text;
|
||||||
|
get_args(args, user_id, text);
|
||||||
|
send_request(td_api::make_object<td_api::setUserSupportInfo>(user_id, as_formatted_text(text)));
|
||||||
} 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()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user