Support editMessageMedia for business messages.

This commit is contained in:
levlam 2024-06-11 22:44:26 +03:00
parent c8079841ed
commit 6c01c85d27

View File

@ -10386,6 +10386,7 @@ td::Status Client::process_edit_message_live_location_query(PromisedQueryPtr &qu
}
td::Status Client::process_edit_message_media_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_));
@ -10404,10 +10405,30 @@ td::Status Client::process_edit_message_media_query(PromisedQueryPtr &query) {
} else {
resolve_reply_markup_bot_usernames(
std::move(reply_markup), std::move(query),
[this, chat_id = chat_id.str(), message_id, input_message_content = std::move(input_media)](
object_ptr<td_api::ReplyMarkup> reply_markup, PromisedQueryPtr query) mutable {
[this, business_connection_id = business_connection_id.str(), chat_id_str = chat_id.str(), message_id,
input_message_content = std::move(input_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,
input_message_content = std::move(input_message_content), reply_markup = std::move(reply_markup)](
const BusinessConnection *business_connection, PromisedQueryPtr query) mutable {
send_request(make_object<td_api::editBusinessMessageMedia>(business_connection_id, chat_id,
message_id, std::move(reply_markup),
std::move(input_message_content)),
td::make_unique<TdOnReturnBusinessMessageCallback>(this, business_connection_id,
std::move(query)));
});
}
check_message(
chat_id, message_id, false, AccessRights::Edit, "message to edit", std::move(query),
chat_id_str, message_id, false, AccessRights::Edit, "message to edit", std::move(query),
[this, reply_markup = std::move(reply_markup), input_message_content = std::move(input_message_content)](
int64 chat_id, int64 message_id, PromisedQueryPtr query) mutable {
send_request(make_object<td_api::editMessageMedia>(chat_id, message_id, std::move(reply_markup),