Support editMessageCaption for business messages.

This commit is contained in:
levlam 2024-06-11 22:50:39 +03:00
parent 6c01c85d27
commit f75e2155c1

View File

@ -10441,6 +10441,7 @@ td::Status Client::process_edit_message_media_query(PromisedQueryPtr &query) {
}
td::Status Client::process_edit_message_caption_query(PromisedQueryPtr &query) {
auto business_connection_id = query->arg("business_connection_id");
auto chat_id = query->arg("chat_id");
auto message_id = get_message_id(query.get());
TRY_RESULT(reply_markup, get_reply_markup(query.get(), bot_user_ids_));
@ -10460,9 +10461,29 @@ td::Status Client::process_edit_message_caption_query(PromisedQueryPtr &query) {
} else {
resolve_reply_markup_bot_usernames(
std::move(reply_markup), std::move(query),
[this, chat_id = chat_id.str(), message_id, caption = std::move(caption), show_caption_above_media](
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
check_message(chat_id, message_id, false, AccessRights::Edit, "message to edit", std::move(query),
[this, business_connection_id = business_connection_id.str(), chat_id_str = chat_id.str(), message_id,
caption = std::move(caption),
show_caption_above_media](object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
if (!business_connection_id.empty()) {
auto r_chat_id = get_business_connection_chat_id(chat_id_str);
if (r_chat_id.is_error()) {
return fail_query_with_error(std::move(query), 400, r_chat_id.error().message());
}
auto chat_id = r_chat_id.move_as_ok();
return check_business_connection(
business_connection_id, std::move(query),
[this, business_connection_id, chat_id, message_id, reply_markup = std::move(reply_markup),
caption = std::move(caption), show_caption_above_media](const BusinessConnection *business_connection,
PromisedQueryPtr query) mutable {
send_request(make_object<td_api::editBusinessMessageCaption>(
business_connection_id, chat_id, message_id, std::move(reply_markup),
std::move(caption), show_caption_above_media),
td::make_unique<TdOnReturnBusinessMessageCallback>(this, business_connection_id,
std::move(query)));
});
}
check_message(chat_id_str, message_id, false, AccessRights::Edit, "message to edit", std::move(query),
[this, reply_markup = std::move(reply_markup), caption = std::move(caption),
show_caption_above_media](int64 chat_id, int64 message_id, PromisedQueryPtr query) mutable {
send_request(