Allow to edit show_caption_above_media.

This commit is contained in:
levlam 2024-05-16 12:42:36 +03:00
parent ec5e2353c3
commit 4434bd327a
5 changed files with 31 additions and 19 deletions

View File

@ -8190,7 +8190,8 @@ editMessageMedia chat_id:int53 message_id:int53 reply_markup:ReplyMarkup input_m
//@message_id Identifier of the message
//@reply_markup The new message reply markup; pass null if none; for bots only
//@caption New message content caption; 0-getOption("message_caption_length_max") characters; pass null to remove caption
editMessageCaption chat_id:int53 message_id:int53 reply_markup:ReplyMarkup caption:formattedText = Message;
//@show_caption_above_media True, if caption must be shown above the media; otherwise caption must be shown below the media. Can be true only for animation, photo, and video messages
editMessageCaption chat_id:int53 message_id:int53 reply_markup:ReplyMarkup caption:formattedText show_caption_above_media:Bool = Message;
//@description Edits the message reply markup; for bots only. Returns the edited message after the edit is completed on the server side
//@chat_id The chat the message belongs to
@ -8224,7 +8225,8 @@ editInlineMessageMedia inline_message_id:string reply_markup:ReplyMarkup input_m
//@inline_message_id Inline message identifier
//@reply_markup The new message reply markup; pass null if none
//@caption New message content caption; pass null to remove caption; 0-getOption("message_caption_length_max") characters
editInlineMessageCaption inline_message_id:string reply_markup:ReplyMarkup caption:formattedText = Ok;
//@show_caption_above_media True, if caption must be shown above the media; otherwise caption must be shown below the media. Can be true only for animation, photo, and video messages
editInlineMessageCaption inline_message_id:string reply_markup:ReplyMarkup caption:formattedText show_caption_above_media:Bool = Ok;
//@description Edits the reply markup of an inline message sent via a bot; for bots only
//@inline_message_id Inline message identifier

View File

@ -25096,7 +25096,7 @@ void MessagesManager::edit_message_live_location(MessageFullId message_full_id,
flags, false /*ignored*/, location.get_input_geo_point(), heading, live_period, proximity_alert_radius);
td_->create_handler<EditMessageQuery>(std::move(promise))
->send(0, dialog_id, m->message_id, string(), vector<tl_object_ptr<telegram_api::MessageEntity>>(),
std::move(input_media), false, std::move(input_reply_markup), get_message_schedule_date(m));
std::move(input_media), false /*ignored*/, std::move(input_reply_markup), get_message_schedule_date(m));
}
void MessagesManager::cancel_edit_message_media(DialogId dialog_id, Message *m, Slice error_message) {
@ -25282,7 +25282,7 @@ void MessagesManager::edit_message_media(MessageFullId message_full_id,
void MessagesManager::edit_message_caption(MessageFullId message_full_id,
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::formattedText> &&input_caption,
tl_object_ptr<td_api::formattedText> &&input_caption, bool invert_media,
Promise<Unit> &&promise) {
auto dialog_id = message_full_id.get_dialog_id();
TRY_RESULT_PROMISE(promise, d, check_dialog_access(dialog_id, true, AccessRights::Edit, "edit_message_caption"));
@ -25298,6 +25298,9 @@ void MessagesManager::edit_message_caption(MessageFullId message_full_id,
if (!can_have_message_content_caption(m->content->get_type())) {
return promise.set_error(Status::Error(400, "There is no caption in the message to edit"));
}
if (invert_media && !is_allowed_invert_caption_message_content(m->content->get_type())) {
invert_media = false;
}
TRY_RESULT_PROMISE(
promise, caption,
@ -25310,7 +25313,7 @@ void MessagesManager::edit_message_caption(MessageFullId message_full_id,
td_->create_handler<EditMessageQuery>(std::move(promise))
->send(1 << 11, dialog_id, m->message_id, caption.text,
get_input_message_entities(td_->user_manager_.get(), caption.entities, "edit_message_caption"), nullptr,
m->invert_media, std::move(input_reply_markup), get_message_schedule_date(m));
invert_media, std::move(input_reply_markup), get_message_schedule_date(m));
}
void MessagesManager::edit_message_reply_markup(MessageFullId message_full_id,
@ -25335,7 +25338,7 @@ void MessagesManager::edit_message_reply_markup(MessageFullId message_full_id,
auto input_reply_markup = get_input_reply_markup(td_->user_manager_.get(), new_reply_markup);
td_->create_handler<EditMessageQuery>(std::move(promise))
->send(0, dialog_id, m->message_id, string(), vector<tl_object_ptr<telegram_api::MessageEntity>>(), nullptr,
m->invert_media, std::move(input_reply_markup), get_message_schedule_date(m));
m->invert_media /*ignored*/, std::move(input_reply_markup), get_message_schedule_date(m));
}
void MessagesManager::edit_inline_message_text(const string &inline_message_id,
@ -25410,7 +25413,8 @@ void MessagesManager::edit_inline_message_live_location(const string &inline_mes
flags, false /*ignored*/, location.get_input_geo_point(), heading, live_period, proximity_alert_radius);
td_->create_handler<EditInlineMessageQuery>(std::move(promise))
->send(0, std::move(input_bot_inline_message_id), "", vector<tl_object_ptr<telegram_api::MessageEntity>>(),
std::move(input_media), false, get_input_reply_markup(td_->user_manager_.get(), new_reply_markup));
std::move(input_media), false /*ignored*/,
get_input_reply_markup(td_->user_manager_.get(), new_reply_markup));
}
void MessagesManager::edit_inline_message_media(const string &inline_message_id,
@ -25460,7 +25464,7 @@ void MessagesManager::edit_inline_message_media(const string &inline_message_id,
void MessagesManager::edit_inline_message_caption(const string &inline_message_id,
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::formattedText> &&input_caption,
Promise<Unit> &&promise) {
bool invert_media, Promise<Unit> &&promise) {
CHECK(td_->auth_manager_->is_bot());
TRY_RESULT_PROMISE(promise, caption,
@ -25477,7 +25481,7 @@ void MessagesManager::edit_inline_message_caption(const string &inline_message_i
td_->create_handler<EditInlineMessageQuery>(std::move(promise))
->send(1 << 11, std::move(input_bot_inline_message_id), caption.text,
get_input_message_entities(td_->user_manager_.get(), caption.entities, "edit_inline_message_caption"),
nullptr, false, get_input_reply_markup(td_->user_manager_.get(), new_reply_markup));
nullptr, invert_media, get_input_reply_markup(td_->user_manager_.get(), new_reply_markup));
}
void MessagesManager::edit_inline_message_reply_markup(const string &inline_message_id,
@ -25495,7 +25499,7 @@ void MessagesManager::edit_inline_message_reply_markup(const string &inline_mess
td_->create_handler<EditInlineMessageQuery>(std::move(promise))
->send(0, std::move(input_bot_inline_message_id), string(), vector<tl_object_ptr<telegram_api::MessageEntity>>(),
nullptr, false, get_input_reply_markup(td_->user_manager_.get(), new_reply_markup));
nullptr, false /*ignored*/, get_input_reply_markup(td_->user_manager_.get(), new_reply_markup));
}
void MessagesManager::edit_message_scheduling_state(
@ -25527,7 +25531,7 @@ void MessagesManager::edit_message_scheduling_state(
if (schedule_date > 0) {
td_->create_handler<EditMessageQuery>(std::move(promise))
->send(0, dialog_id, m->message_id, string(), vector<tl_object_ptr<telegram_api::MessageEntity>>(), nullptr,
m->invert_media, nullptr, schedule_date);
m->invert_media /*ignored*/, nullptr, schedule_date);
} else {
td_->create_handler<SendScheduledMessageQuery>(std::move(promise))->send(dialog_id, m->message_id);
}

View File

@ -476,7 +476,8 @@ class MessagesManager final : public Actor {
tl_object_ptr<td_api::InputMessageContent> &&input_message_content, Promise<Unit> &&promise);
void edit_message_caption(MessageFullId message_full_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::formattedText> &&input_caption, Promise<Unit> &&promise);
tl_object_ptr<td_api::formattedText> &&input_caption, bool invert_media,
Promise<Unit> &&promise);
void edit_message_reply_markup(MessageFullId message_full_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
Promise<Unit> &&promise);
@ -495,7 +496,8 @@ class MessagesManager final : public Actor {
Promise<Unit> &&promise);
void edit_inline_message_caption(const string &inline_message_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::formattedText> &&input_caption, Promise<Unit> &&promise);
tl_object_ptr<td_api::formattedText> &&input_caption, bool invert_media,
Promise<Unit> &&promise);
void edit_inline_message_reply_markup(const string &inline_message_id,
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup, Promise<Unit> &&promise);

View File

@ -1271,10 +1271,11 @@ class EditMessageCaptionRequest final : public RequestOnceActor {
MessageFullId message_full_id_;
tl_object_ptr<td_api::ReplyMarkup> reply_markup_;
tl_object_ptr<td_api::formattedText> caption_;
bool invert_media_;
void do_run(Promise<Unit> &&promise) final {
td_->messages_manager_->edit_message_caption(message_full_id_, std::move(reply_markup_), std::move(caption_),
std::move(promise));
invert_media_, std::move(promise));
}
void do_send_result() final {
@ -1284,11 +1285,12 @@ class EditMessageCaptionRequest final : public RequestOnceActor {
public:
EditMessageCaptionRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
tl_object_ptr<td_api::ReplyMarkup> reply_markup,
tl_object_ptr<td_api::formattedText> caption)
tl_object_ptr<td_api::formattedText> caption, bool invert_media)
: RequestOnceActor(std::move(td), request_id)
, message_full_id_(DialogId(dialog_id), MessageId(message_id))
, reply_markup_(std::move(reply_markup))
, caption_(std::move(caption)) {
, caption_(std::move(caption))
, invert_media_(invert_media) {
}
};
@ -5704,7 +5706,7 @@ void Td::on_request(uint64 id, td_api::editMessageMedia &request) {
void Td::on_request(uint64 id, td_api::editMessageCaption &request) {
CREATE_REQUEST(EditMessageCaptionRequest, request.chat_id_, request.message_id_, std::move(request.reply_markup_),
std::move(request.caption_));
std::move(request.caption_), request.show_caption_above_media_);
}
void Td::on_request(uint64 id, td_api::editMessageReplyMarkup &request) {
@ -5743,7 +5745,8 @@ void Td::on_request(uint64 id, td_api::editInlineMessageCaption &request) {
CLEAN_INPUT_STRING(request.inline_message_id_);
CREATE_OK_REQUEST_PROMISE();
messages_manager_->edit_inline_message_caption(request.inline_message_id_, std::move(request.reply_markup_),
std::move(request.caption_), std::move(promise));
std::move(request.caption_), request.show_caption_above_media_,
std::move(promise));
}
void Td::on_request(uint64 id, td_api::editInlineMessageReplyMarkup &request) {

View File

@ -4990,7 +4990,8 @@ class CliClient final : public Actor {
MessageId message_id;
string caption;
get_args(args, chat_id, message_id, caption);
send_request(td_api::make_object<td_api::editMessageCaption>(chat_id, message_id, nullptr, as_caption(caption)));
send_request(td_api::make_object<td_api::editMessageCaption>(chat_id, message_id, nullptr, as_caption(caption),
show_caption_above_media_));
} else if (op == "emd") {
ChatId chat_id;
MessageId message_id;