Add and use get_story_content_duration.

This commit is contained in:
levlam 2023-05-24 16:23:05 +03:00
parent 9610b06abc
commit 41da14fd17
5 changed files with 17 additions and 3 deletions

View File

@ -5859,7 +5859,7 @@ int32 get_message_content_duration(const MessageContent *content, const Td *td)
return td->voice_notes_manager_->get_voice_note_duration(voice_file_id);
}
default:
return 0;
return -1;
}
}

View File

@ -217,7 +217,7 @@ void MessageExtendedMedia::delete_thumbnail(Td *td) {
int32 MessageExtendedMedia::get_duration(const Td *td) const {
if (!has_media_timestamp()) {
return 0;
return -1;
}
return td->videos_manager_->get_video_duration(video_file_id_);
}

View File

@ -246,4 +246,16 @@ vector<FileId> get_story_content_file_ids(const Td *td, const StoryContent *cont
}
}
int32 get_story_content_duration(const Td *td, const StoryContent *content) {
CHECK(content != nullptr);
switch (content->get_type()) {
case StoryContentType::Video: {
auto file_id = static_cast<const StoryContentVideo *>(content)->file_id_;
return td->videos_manager_->get_video_duration(file_id);
}
default:
return -1;
}
}
} // namespace td

View File

@ -44,4 +44,6 @@ td_api::object_ptr<td_api::StoryContent> get_story_content_object(Td *td, const
vector<FileId> get_story_content_file_ids(const Td *td, const StoryContent *content);
int32 get_story_content_duration(const Td *td, const StoryContent *content);
} // namespace td

View File

@ -252,7 +252,7 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
td_->contacts_manager_->get_user_id_object(dialog_id.get_user_id(), "get_story_object"), story->date_,
story->is_pinned_, story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules),
story->is_public_, story->is_for_close_friends_, get_story_content_object(td_, story->content_.get()),
get_formatted_text_object(story->caption_, true, -1));
get_formatted_text_object(story->caption_, true, get_story_content_duration(td_, story->content_.get())));
}
td_api::object_ptr<td_api::stories> StoryManager::get_stories_object(int32 total_count,