Support live_period in edtiMessageLiveLocation.

This commit is contained in:
levlam 2024-05-02 16:24:35 +03:00
parent 0a06d75c1a
commit 140c97f8ac
5 changed files with 22 additions and 11 deletions

View File

@ -8112,9 +8112,11 @@ editMessageText chat_id:int53 message_id:int53 reply_markup:ReplyMarkup input_me
//@message_id Identifier of the message
//@reply_markup The new message reply markup; pass null if none; for bots only
//@location New location content of the message; pass null to stop sharing the live location
//@live_period New time relative to the message send date, for which the location can be updated, in seconds. If 0x7FFFFFFF specified, then the location can be updated forever.
//-Otherwise, must not exceed the current live_period by more than a day, and the live location expiration date must remain in the next 90 days. Pass 0 to keep the current live_period
//@heading The new direction in which the location moves, in degrees; 1-360. Pass 0 if unknown
//@proximity_alert_radius The new maximum distance for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled
editMessageLiveLocation chat_id:int53 message_id:int53 reply_markup:ReplyMarkup location:location heading:int32 proximity_alert_radius:int32 = Message;
editMessageLiveLocation chat_id:int53 message_id:int53 reply_markup:ReplyMarkup location:location live_period:int32 heading:int32 proximity_alert_radius:int32 = Message;
//@description Edits the content of a message with an animation, an audio, a document, a photo or a video, including message caption. If only the caption needs to be edited, use editMessageCaption instead.
//-The media can't be edited if the message was set to self-destruct or to a self-destructing media. The type of message content in an album can't be changed with exception of replacing a photo with a video or vice versa. Returns the edited message after the edit is completed on the server side

View File

@ -25053,8 +25053,8 @@ void MessagesManager::edit_message_text(MessageFullId message_full_id,
void MessagesManager::edit_message_live_location(MessageFullId message_full_id,
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::location> &&input_location, int32 heading,
int32 proximity_alert_radius, Promise<Unit> &&promise) {
tl_object_ptr<td_api::location> &&input_location, int32 live_period,
int32 heading, int32 proximity_alert_radius, 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_live_location"));
@ -25090,12 +25090,15 @@ void MessagesManager::edit_message_live_location(MessageFullId message_full_id,
if (location.empty()) {
flags |= telegram_api::inputMediaGeoLive::STOPPED_MASK;
}
if (live_period != 0) {
flags |= telegram_api::inputMediaGeoLive::PERIOD_MASK;
}
if (heading != 0) {
flags |= telegram_api::inputMediaGeoLive::HEADING_MASK;
}
flags |= telegram_api::inputMediaGeoLive::PROXIMITY_NOTIFICATION_RADIUS_MASK;
auto input_media = telegram_api::make_object<telegram_api::inputMediaGeoLive>(
flags, false /*ignored*/, location.get_input_geo_point(), heading, 0, proximity_alert_radius);
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));

View File

@ -464,7 +464,7 @@ class MessagesManager final : public Actor {
tl_object_ptr<td_api::InputMessageContent> &&input_message_content, Promise<Unit> &&promise);
void edit_message_live_location(MessageFullId message_full_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::location> &&input_location, int32 heading,
tl_object_ptr<td_api::location> &&input_location, int32 live_period, int32 heading,
int32 proximity_alert_radius, Promise<Unit> &&promise);
void edit_message_media(MessageFullId message_full_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,

View File

@ -1212,12 +1212,14 @@ class EditMessageLiveLocationRequest final : public RequestOnceActor {
MessageFullId message_full_id_;
tl_object_ptr<td_api::ReplyMarkup> reply_markup_;
tl_object_ptr<td_api::location> location_;
int32 live_period_;
int32 heading_;
int32 proximity_alert_radius_;
void do_run(Promise<Unit> &&promise) final {
td_->messages_manager_->edit_message_live_location(message_full_id_, std::move(reply_markup_), std::move(location_),
heading_, proximity_alert_radius_, std::move(promise));
live_period_, heading_, proximity_alert_radius_,
std::move(promise));
}
void do_send_result() final {
@ -1227,11 +1229,13 @@ class EditMessageLiveLocationRequest final : public RequestOnceActor {
public:
EditMessageLiveLocationRequest(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::location> location, int32 heading, int32 proximity_alert_radius)
tl_object_ptr<td_api::location> location, int32 live_period, int32 heading,
int32 proximity_alert_radius)
: RequestOnceActor(std::move(td), request_id)
, message_full_id_(DialogId(dialog_id), MessageId(message_id))
, reply_markup_(std::move(reply_markup))
, location_(std::move(location))
, live_period_(live_period)
, heading_(heading)
, proximity_alert_radius_(proximity_alert_radius) {
}
@ -5776,7 +5780,7 @@ void Td::on_request(uint64 id, td_api::editMessageText &request) {
void Td::on_request(uint64 id, td_api::editMessageLiveLocation &request) {
CREATE_REQUEST(EditMessageLiveLocationRequest, request.chat_id_, request.message_id_,
std::move(request.reply_markup_), std::move(request.location_), request.heading_,
std::move(request.reply_markup_), std::move(request.location_), request.live_period_, request.heading_,
request.proximity_alert_radius_);
}

View File

@ -5011,12 +5011,14 @@ class CliClient final : public Actor {
MessageId message_id;
string latitude;
string longitude;
int32 live_period;
string accuracy;
int32 heading;
int32 proximity_alert_radius;
get_args(args, chat_id, message_id, latitude, longitude, accuracy, heading, proximity_alert_radius);
send_request(td_api::make_object<td_api::editMessageLiveLocation>(
chat_id, message_id, nullptr, as_location(latitude, longitude, accuracy), heading, proximity_alert_radius));
get_args(args, chat_id, message_id, latitude, longitude, live_period, accuracy, heading, proximity_alert_radius);
send_request(td_api::make_object<td_api::editMessageLiveLocation>(chat_id, message_id, nullptr,
as_location(latitude, longitude, accuracy),
live_period, heading, proximity_alert_radius));
} else if (op == "emss") {
ChatId chat_id;
MessageId message_id;