Support editMessageLiveLocation for business messages.

This commit is contained in:
levlam 2024-06-11 22:41:59 +03:00
parent 7ee51f8c6d
commit c8079841ed

View File

@ -10330,6 +10330,7 @@ td::Status Client::process_edit_message_live_location_query(PromisedQueryPtr &qu
if (query->method() == "editmessagelivelocation") {
TRY_RESULT_ASSIGN(location, get_location(query.get()));
}
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_));
@ -10348,9 +10349,29 @@ td::Status Client::process_edit_message_live_location_query(PromisedQueryPtr &qu
} else {
resolve_reply_markup_bot_usernames(
std::move(reply_markup), std::move(query),
[this, chat_id = chat_id.str(), message_id, location = std::move(location), live_period, heading,
[this, business_connection_id = business_connection_id.str(), chat_id_str = chat_id.str(), message_id,
location = std::move(location), live_period, heading,
proximity_alert_radius](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),
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, location = std::move(location), live_period,
heading, proximity_alert_radius, reply_markup = std::move(reply_markup)](
const BusinessConnection *business_connection, PromisedQueryPtr query) mutable {
send_request(make_object<td_api::editBusinessMessageLiveLocation>(
business_connection_id, chat_id, message_id, std::move(reply_markup),
std::move(location), live_period, heading, proximity_alert_radius),
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, location = std::move(location), live_period, heading, proximity_alert_radius,
reply_markup = std::move(reply_markup)](int64 chat_id, int64 message_id,
PromisedQueryPtr query) mutable {