From f869eca9c496792c279d64f8311ed4c46f2ebc51 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 6 Jun 2023 16:07:29 +0300 Subject: [PATCH] Add StoryManager::get_story_duration. --- td/telegram/StoryManager.cpp | 15 +++++++++++++++ td/telegram/StoryManager.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index c965aa285..e718b1993 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -544,6 +544,21 @@ bool StoryManager::have_story(StoryFullId story_full_id) const { return get_story(story_full_id) != nullptr; } +int32 StoryManager::get_story_duration(StoryFullId story_full_id) const { + auto story = get_story(story_full_id); + if (story == nullptr) { + return -1; + } + auto *content = story->content_.get(); + auto it = being_edited_stories_.find(story_full_id); + if (it != being_edited_stories_.end()) { + if (it->second->content_ != nullptr) { + content = it->second->content_.get(); + } + } + return get_story_content_duration(td_, content); +} + td_api::object_ptr StoryManager::get_story_object(StoryFullId story_full_id) const { return get_story_object(story_full_id, get_story(story_full_id)); } diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index c2390278b..76380073b 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -108,6 +108,8 @@ class StoryManager final : public Actor { bool have_story(StoryFullId story_full_id) const; + int32 get_story_duration(StoryFullId story_full_id) const; + td_api::object_ptr get_story_object(StoryFullId story_full_id) const; td_api::object_ptr get_stories_object(int32 total_count,