Add td_api::reorderBotMediaPreviews.
This commit is contained in:
parent
1abbbc3778
commit
fceb1437d7
@ -10637,7 +10637,13 @@ addBotMediaPreview bot_user_id:int53 language_code:string content:InputStoryCont
|
||||
//@content Content of the new preview
|
||||
editBotMediaPreview bot_user_id:int53 language_code:string file_id:int32 content:InputStoryContent = StoryContent;
|
||||
|
||||
//@description Delete media preview from the list of bot's media previews
|
||||
//@description Changes order of media previews in the list of bot's media previews
|
||||
//@bot_user_id Identifier of the target bot
|
||||
//@language_code Language code of the media previews to reorder
|
||||
//@file_ids File identifiers of the media in the new order
|
||||
reorderBotMediaPreviews bot_user_id:int53 language_code:string file_ids:vector<int32> = Ok;
|
||||
|
||||
//@description Delete media previews from the list of bot's media previews
|
||||
//@bot_user_id Identifier of the target bot
|
||||
//@language_code Language code of the media previews to delete
|
||||
//@file_ids File identifiers of the media to delete
|
||||
|
@ -221,6 +221,34 @@ class BotInfoManager::AddPreviewMediaQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class ReorderPreviewMediasQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit ReorderPreviewMediasQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(UserId bot_user_id, telegram_api::object_ptr<telegram_api::InputUser> input_user,
|
||||
const string &language_code, vector<telegram_api::object_ptr<telegram_api::InputMedia>> input_media) {
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::bots_reorderPreviewMedias(std::move(input_user), language_code, std::move(input_media)),
|
||||
{{bot_user_id}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::bots_reorderPreviewMedias>(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 DeletePreviewMediaQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
@ -751,6 +779,22 @@ telegram_api::object_ptr<telegram_api::InputMedia> BotInfoManager::get_fake_inpu
|
||||
}
|
||||
}
|
||||
|
||||
void BotInfoManager::reorder_bot_media_previews(UserId bot_user_id, const string &language_code,
|
||||
const vector<int32> &file_ids, Promise<Unit> &&promise) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, get_media_preview_bot_input_user(bot_user_id, true));
|
||||
TRY_STATUS_PROMISE(promise, validate_bot_language_code(language_code));
|
||||
vector<telegram_api::object_ptr<telegram_api::InputMedia>> input_medias;
|
||||
for (auto file_id : file_ids) {
|
||||
auto input_media = get_fake_input_media(FileId(file_id, 0));
|
||||
if (input_media == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "Wrong media to delete specified"));
|
||||
}
|
||||
input_medias.push_back(std::move(input_media));
|
||||
}
|
||||
td_->create_handler<ReorderPreviewMediasQuery>(std::move(promise))
|
||||
->send(bot_user_id, std::move(input_user), language_code, std::move(input_medias));
|
||||
}
|
||||
|
||||
void BotInfoManager::delete_bot_media_previews(UserId bot_user_id, const string &language_code,
|
||||
const vector<int32> &file_ids, Promise<Unit> &&promise) {
|
||||
TRY_RESULT_PROMISE(promise, input_user, get_media_preview_bot_input_user(bot_user_id, true));
|
||||
|
@ -55,6 +55,9 @@ class BotInfoManager final : public Actor {
|
||||
td_api::object_ptr<td_api::InputStoryContent> &&input_content,
|
||||
Promise<td_api::object_ptr<td_api::StoryContent>> &&promise);
|
||||
|
||||
void reorder_bot_media_previews(UserId bot_user_id, const string &language_code, const vector<int32> &file_ids,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void delete_bot_media_previews(UserId bot_user_id, const string &language_code, const vector<int32> &file_ids,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
|
@ -7917,6 +7917,13 @@ void Td::on_request(uint64 id, td_api::editBotMediaPreview &request) {
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::reorderBotMediaPreviews &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
bot_info_manager_->reorder_bot_media_previews(UserId(request.bot_user_id_), request.language_code_, request.file_ids_,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::deleteBotMediaPreviews &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
|
@ -1463,6 +1463,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::editBotMediaPreview &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::reorderBotMediaPreviews &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::deleteBotMediaPreviews &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setBotName &request);
|
||||
|
@ -6596,6 +6596,13 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::editBotMediaPreview>(
|
||||
bot_user_id, language_code, file_id,
|
||||
td_api::make_object<td_api::inputStoryContentVideo>(as_input_file(video), Auto(), 0.0, 1.5, true)));
|
||||
} else if (op == "rbmp") {
|
||||
UserId bot_user_id;
|
||||
string language_code;
|
||||
string file_ids;
|
||||
get_args(args, bot_user_id, language_code, file_ids);
|
||||
send_request(td_api::make_object<td_api::reorderBotMediaPreviews>(bot_user_id, language_code,
|
||||
to_integers<int32>(file_ids)));
|
||||
} else if (op == "dbmp") {
|
||||
UserId bot_user_id;
|
||||
string language_code;
|
||||
|
Loading…
Reference in New Issue
Block a user