diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 99fabd9c0..dfa65106a 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3022,7 +3022,7 @@ messageExpiredVoiceNote = MessageContent; //@description A message with a location //@location The location description -//@live_period Time relative to the message send date, for which the location can be updated, in seconds +//@live_period Time relative to the message send date, for which the location can be updated, in seconds; if 2147483647, then location can be updated forever //@expires_in Left time for which the location can be updated, in seconds. updateMessageContent is not sent when this field changes //@heading For live locations, a direction in which the location moves, in degrees; 1-360. If 0 the direction is unknown //@proximity_alert_radius For live locations, a maximum distance to another chat member for proximity alerts, in meters (0-100000). 0 if the notification is disabled. Available only to the message sender @@ -3462,7 +3462,7 @@ inputMessageVoiceNote voice_note:InputFile duration:int32 waveform:bytes caption //@description A message with a location //@location Location to be sent -//@live_period Period for which the location can be updated, in seconds; must be between 60 and 86400 for a live location and 0 otherwise +//@live_period Period for which the location can be updated, in seconds; must be between 60 and 86400 for a temporary live location, 2147483647 for permanent live location, and 0 otherwise //@heading For live locations, a direction in which the location moves, in degrees; 1-360. Pass 0 if unknown //@proximity_alert_radius For live locations, a maximum distance to another chat member for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled. Can't be enabled in channels and Saved Messages inputMessageLocation location:location live_period:int32 heading:int32 proximity_alert_radius:int32 = InputMessageContent; diff --git a/td/telegram/Location.cpp b/td/telegram/Location.cpp index 31199705b..46061086d 100644 --- a/td/telegram/Location.cpp +++ b/td/telegram/Location.cpp @@ -10,6 +10,7 @@ #include "td/telegram/Td.h" #include +#include namespace td { @@ -157,7 +158,8 @@ Result process_input_message_location( constexpr int32 MAX_LIVE_LOCATION_PERIOD = 86400; // seconds, server side limit auto period = input_location->live_period_; - if (period != 0 && (period < MIN_LIVE_LOCATION_PERIOD || period > MAX_LIVE_LOCATION_PERIOD)) { + if (period != 0 && period != std::numeric_limits::max() && + (period < MIN_LIVE_LOCATION_PERIOD || period > MAX_LIVE_LOCATION_PERIOD)) { return Status::Error(400, "Wrong live location period specified"); } diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index b7b257db6..ad18e5f71 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -6940,7 +6940,7 @@ tl_object_ptr get_message_content_object(const MessageCo case MessageContentType::LiveLocation: { const auto *m = static_cast(content); auto passed = max(G()->unix_time() - message_date, 0); - auto expires_in = max(0, m->period - passed); + auto expires_in = m->period == std::numeric_limits::max() ? m->period : max(0, m->period - passed); auto heading = expires_in == 0 ? 0 : m->heading; auto proximity_alert_radius = expires_in == 0 ? 0 : m->proximity_alert_radius; return make_tl_object(m->location.get_location_object(), m->period, expires_in, heading,