Add messageProperties.can_get_link.
This commit is contained in:
parent
db62de6d3e
commit
504ac111af
@ -3840,13 +3840,14 @@ inputMessageForwarded from_chat_id:int53 message_id:int53 in_game_share:Bool cop
|
||||
//@can_be_saved True, if content of the message can be saved locally or copied using inputMessageForwarded or forwardMessages with copy options
|
||||
//@can_be_shared_in_story True, if the message can be shared in a story using inputStoryAreaTypeMessage
|
||||
//@can_get_added_reactions True, if the list of added reactions is available using getMessageAddedReactions
|
||||
//@can_get_link True, if a link can be generated for the message using getMessageLink
|
||||
//@can_get_media_timestamp_links True, if media timestamp links can be generated for media timestamp entities in the message text, caption or link preview description using getMessageLink
|
||||
//@can_get_message_thread True, if information about the message thread is available through getMessageThread and getMessageThreadHistory
|
||||
//@can_get_read_date True, if read date of the message can be received through getMessageReadDate
|
||||
//@can_get_statistics True, if the message statistics are available through getMessageStatistics
|
||||
//@can_get_viewers True, if chat members already viewed the message can be received through getMessageViewers
|
||||
//@can_report_reactions True, if reactions on the message can be reported through reportMessageReactions
|
||||
messageProperties can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_paid:Bool can_be_replied:Bool can_be_replied_in_another_chat:Bool can_be_reported:Bool can_be_saved:Bool can_be_shared_in_story:Bool can_get_added_reactions:Bool can_get_media_timestamp_links:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_statistics:Bool can_get_viewers:Bool can_report_reactions:Bool = MessageProperties;
|
||||
messageProperties can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_paid:Bool can_be_replied:Bool can_be_replied_in_another_chat:Bool can_be_reported:Bool can_be_saved:Bool can_be_shared_in_story:Bool can_get_added_reactions:Bool can_get_link:Bool can_get_media_timestamp_links:Bool can_get_message_thread:Bool can_get_read_date:Bool can_get_statistics:Bool can_get_viewers:Bool can_report_reactions:Bool = MessageProperties;
|
||||
|
||||
|
||||
//@class SearchMessagesFilter @description Represents a filter for message search results
|
||||
@ -8423,7 +8424,7 @@ removeNotification notification_group_id:int32 notification_id:int32 = Ok;
|
||||
removeNotificationGroup notification_group_id:int32 max_notification_id:int32 = Ok;
|
||||
|
||||
|
||||
//@description Returns an HTTPS link to a message in a chat. Available only for already sent messages in supergroups and channels, or if message.can_get_media_timestamp_links and a media timestamp link is generated. This is an offline request
|
||||
//@description Returns an HTTPS link to a message in a chat. Available only if messageProperties.can_get_link, or if messageProperties.can_get_media_timestamp_links and a media timestamp link is generated. This is an offline request
|
||||
//@chat_id Identifier of the chat to which the message belongs
|
||||
//@message_id Identifier of the message
|
||||
//@media_timestamp If not 0, timestamp from which the video/audio/video note/voice note/story playing must start, in seconds. The media can be in the message content or in its link preview
|
||||
|
@ -17310,9 +17310,9 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa
|
||||
const Message *m = get_message_force(d, message_id, "get_message_properties");
|
||||
if (m == nullptr) {
|
||||
if (message_id.is_valid_sponsored()) {
|
||||
return promise.set_value(td_api::make_object<td_api::messageProperties>(false, false, false, false, false, false,
|
||||
false, false, false, false, false, false,
|
||||
false, false, false, false, false));
|
||||
return promise.set_value(td_api::make_object<td_api::messageProperties>(
|
||||
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false));
|
||||
}
|
||||
return promise.set_error(Status::Error(400, "Message not found"));
|
||||
}
|
||||
@ -17362,12 +17362,13 @@ void MessagesManager::get_message_properties(DialogId dialog_id, MessageId messa
|
||||
auto can_get_read_date = can_get_message_read_date(dialog_id, m).is_ok();
|
||||
auto can_get_viewers = can_get_message_viewers(dialog_id, m).is_ok();
|
||||
auto can_get_media_timestamp_links = can_get_media_timestamp_link(dialog_id, m).is_ok();
|
||||
auto can_get_link = can_get_media_timestamp_links && dialog_type == DialogType::Channel;
|
||||
auto can_report_reactions = can_report_message_reactions(dialog_id, m);
|
||||
promise.set_value(td_api::make_object<td_api::messageProperties>(
|
||||
can_delete_for_self, can_delete_for_all_users, can_be_edited, can_be_forwarded, can_be_paid, can_be_replied,
|
||||
can_be_replied_in_another_chat, can_be_reported, can_be_saved, can_be_shared_in_story, can_get_added_reactions,
|
||||
can_get_media_timestamp_links, can_get_message_thread, can_get_read_date, can_get_statistics, can_get_viewers,
|
||||
can_report_reactions));
|
||||
can_get_link, can_get_media_timestamp_links, can_get_message_thread, can_get_read_date, can_get_statistics,
|
||||
can_get_viewers, can_report_reactions));
|
||||
}
|
||||
|
||||
bool MessagesManager::is_message_edited_recently(MessageFullId message_full_id, int32 seconds) {
|
||||
@ -17482,19 +17483,11 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(MessageFullId
|
||||
auto *m = get_message_force(d, message_full_id.get_message_id(), "get_message_link");
|
||||
TRY_STATUS(can_get_media_timestamp_link(dialog_id, m));
|
||||
|
||||
if (media_timestamp <= 0 || !can_message_content_have_media_timestamp(m->content.get())) {
|
||||
media_timestamp = 0;
|
||||
}
|
||||
if (media_timestamp != 0) {
|
||||
for_group = false;
|
||||
auto duration = get_message_content_media_duration(m->content.get(), td_);
|
||||
if (duration != 0 && media_timestamp > duration) {
|
||||
media_timestamp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
auto message_id = m->message_id;
|
||||
if (dialog_id.get_type() != DialogType::Channel) {
|
||||
if (media_timestamp == 0) {
|
||||
return Status::Error(400, "Message can't have link");
|
||||
}
|
||||
CHECK(m->forward_info != nullptr);
|
||||
|
||||
auto origin_message_full_id = m->forward_info->get_origin_message_full_id();
|
||||
@ -17512,9 +17505,19 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(MessageFullId
|
||||
for_group = true; // default is true
|
||||
}
|
||||
}
|
||||
if (media_timestamp <= 0 || !can_message_content_have_media_timestamp(m->content.get())) {
|
||||
media_timestamp = 0;
|
||||
}
|
||||
if (media_timestamp != 0) {
|
||||
for_group = false;
|
||||
auto duration = get_message_content_media_duration(m->content.get(), td_);
|
||||
if (duration != 0 && media_timestamp > duration) {
|
||||
media_timestamp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_forum = td_->dialog_manager_->is_forum_channel(dialog_id);
|
||||
if (!is_forum &&
|
||||
if (in_message_thread && !is_forum &&
|
||||
(!m->top_thread_message_id.is_valid() || !m->top_thread_message_id.is_server() ||
|
||||
is_deleted_message(d, m->top_thread_message_id) || td_->dialog_manager_->is_broadcast_channel(dialog_id))) {
|
||||
in_message_thread = false;
|
||||
@ -17530,6 +17533,7 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(MessageFullId
|
||||
|
||||
if (in_message_thread && !is_forum) {
|
||||
// try to generate a comment link
|
||||
CHECK(dialog_id == d->dialog_id);
|
||||
auto *top_m = get_message_force(d, m->top_thread_message_id, "get_public_message_link");
|
||||
if (is_discussion_message(dialog_id, top_m) && is_active_message_reply_info(dialog_id, top_m->reply_info)) {
|
||||
auto linked_message_full_id = top_m->forward_info->get_last_message_full_id();
|
||||
|
Loading…
Reference in New Issue
Block a user