Improve can_message_content_have_media_timestamp.
This commit is contained in:
parent
5d579af30a
commit
bc5efb771d
@ -2810,6 +2810,19 @@ void remove_message_content_web_page(MessageContent *content) {
|
|||||||
static_cast<MessageText *>(content)->web_page_id = WebPageId();
|
static_cast<MessageText *>(content)->web_page_id = WebPageId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool can_message_content_have_media_timestamp(const MessageContent *content) {
|
||||||
|
CHECK(content != nullptr);
|
||||||
|
switch (content->get_type()) {
|
||||||
|
case MessageContentType::Audio:
|
||||||
|
case MessageContentType::Video:
|
||||||
|
case MessageContentType::VideoNote:
|
||||||
|
case MessageContentType::VoiceNote:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return has_message_content_web_page(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void set_message_content_poll_answer(Td *td, const MessageContent *content, FullMessageId full_message_id,
|
void set_message_content_poll_answer(Td *td, const MessageContent *content, FullMessageId full_message_id,
|
||||||
vector<int32> &&option_ids, Promise<Unit> &&promise) {
|
vector<int32> &&option_ids, Promise<Unit> &&promise) {
|
||||||
CHECK(content->get_type() == MessageContentType::Poll);
|
CHECK(content->get_type() == MessageContentType::Poll);
|
||||||
|
@ -149,6 +149,8 @@ bool has_message_content_web_page(const MessageContent *content);
|
|||||||
|
|
||||||
void remove_message_content_web_page(MessageContent *content);
|
void remove_message_content_web_page(MessageContent *content);
|
||||||
|
|
||||||
|
bool can_message_content_have_media_timestamp(const MessageContent *content);
|
||||||
|
|
||||||
void set_message_content_poll_answer(Td *td, const MessageContent *content, FullMessageId full_message_id,
|
void set_message_content_poll_answer(Td *td, const MessageContent *content, FullMessageId full_message_id,
|
||||||
vector<int32> &&option_ids, Promise<Unit> &&promise);
|
vector<int32> &&option_ids, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
@ -335,10 +335,4 @@ bool can_have_message_content_caption(MessageContentType content_type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool can_have_media_timestamp(MessageContentType content_type) {
|
|
||||||
return content_type == MessageContentType::Audio || content_type == MessageContentType::Text ||
|
|
||||||
content_type == MessageContentType::Video || content_type == MessageContentType::VideoNote ||
|
|
||||||
content_type == MessageContentType::VoiceNote;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -75,8 +75,6 @@ bool is_service_message_content(MessageContentType content_type);
|
|||||||
|
|
||||||
bool can_have_message_content_caption(MessageContentType content_type);
|
bool can_have_message_content_caption(MessageContentType content_type);
|
||||||
|
|
||||||
bool can_have_media_timestamp(MessageContentType content_type);
|
|
||||||
|
|
||||||
struct MessageContentTypeHash {
|
struct MessageContentTypeHash {
|
||||||
std::size_t operator()(MessageContentType content_type) const {
|
std::size_t operator()(MessageContentType content_type) const {
|
||||||
return std::hash<int32>()(static_cast<int32>(content_type));
|
return std::hash<int32>()(static_cast<int32>(content_type));
|
||||||
|
@ -17318,7 +17318,7 @@ Result<std::pair<string, bool>> MessagesManager::get_message_link(FullMessageId
|
|||||||
for_comment = false;
|
for_comment = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (media_timestamp <= 0 || !can_have_media_timestamp(m->content->get_type())) {
|
if (media_timestamp <= 0 || !can_message_content_have_media_timestamp(m->content.get())) {
|
||||||
media_timestamp = 0;
|
media_timestamp = 0;
|
||||||
}
|
}
|
||||||
if (media_timestamp != 0) {
|
if (media_timestamp != 0) {
|
||||||
@ -17581,7 +17581,7 @@ td_api::object_ptr<td_api::messageLinkInfo> MessagesManager::get_message_link_in
|
|||||||
message = get_message_object(dialog_id, m);
|
message = get_message_object(dialog_id, m);
|
||||||
for_album = !info.is_single && m->media_album_id != 0;
|
for_album = !info.is_single && m->media_album_id != 0;
|
||||||
for_comment = (info.comment_dialog_id.is_valid() || info.for_comment) && m->top_thread_message_id.is_valid();
|
for_comment = (info.comment_dialog_id.is_valid() || info.for_comment) && m->top_thread_message_id.is_valid();
|
||||||
if (can_have_media_timestamp(m->content->get_type())) {
|
if (can_message_content_have_media_timestamp(m->content.get())) {
|
||||||
auto duration = get_message_content_duration(m->content.get(), td_);
|
auto duration = get_message_content_duration(m->content.get(), td_);
|
||||||
if (duration == 0 || info.media_timestamp <= duration) {
|
if (duration == 0 || info.media_timestamp <= duration) {
|
||||||
media_timestamp = info.media_timestamp;
|
media_timestamp = info.media_timestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user