diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index bc3f73d7e..29001e1be 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -803,6 +803,28 @@ void StoryManager::Story::parse(ParserT &parser) { } } +template +void StoryManager::StoryInfo::store(StorerT &storer) const { + using td::store; + BEGIN_STORE_FLAGS(); + STORE_FLAG(is_for_close_friends_); + END_STORE_FLAGS(); + store(story_id_, storer); + store(date_, storer); + store(expire_date_, storer); +} + +template +void StoryManager::StoryInfo::parse(ParserT &parser) { + using td::parse; + BEGIN_PARSE_FLAGS(); + PARSE_FLAG(is_for_close_friends_); + END_PARSE_FLAGS(); + parse(story_id_, parser); + parse(date_, parser); + parse(expire_date_, parser); +} + template void StoryManager::PendingStory::store(StorerT &storer) const { using td::store; @@ -1997,18 +2019,26 @@ void StoryManager::unregister_story(StoryFullId story_full_id, FullMessageId ful } } -td_api::object_ptr StoryManager::get_story_info_object(StoryFullId story_full_id) const { - return get_story_info_object(story_full_id, get_story(story_full_id)); +StoryManager::StoryInfo StoryManager::get_story_info(StoryFullId story_full_id) const { + const auto *story = get_story(story_full_id); + if (story == nullptr || !is_active_story(story)) { + return {}; + } + StoryInfo story_info; + story_info.story_id_ = story_full_id.get_story_id(); + story_info.date_ = story->date_; + story_info.expire_date_ = story->expire_date_; + story_info.is_for_close_friends_ = story->is_for_close_friends_; + return story_info; } -td_api::object_ptr StoryManager::get_story_info_object(StoryFullId story_full_id, - const Story *story) const { - if (story == nullptr || !is_active_story(story)) { +td_api::object_ptr StoryManager::get_story_info_object(StoryFullId story_full_id) const { + auto story_info = get_story_info(story_full_id); + if (!story_info.story_id_.is_valid()) { return nullptr; } - - return td_api::make_object(story_full_id.get_story_id().get(), story->date_, - story->is_for_close_friends_); + return td_api::make_object(story_info.story_id_.get(), story_info.date_, + story_info.is_for_close_friends_); } td_api::object_ptr StoryManager::get_story_object(StoryFullId story_full_id) const { diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index 7ac4c3dab..de58f3fba 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -72,6 +72,19 @@ class StoryManager final : public Actor { void parse(ParserT &parser); }; + struct StoryInfo { + StoryId story_id_; + int32 date_ = 0; + int32 expire_date_ = 0; + bool is_for_close_friends_ = false; + + template + void store(StorerT &storer) const; + + template + void parse(ParserT &parser); + }; + struct BeingEditedStory { unique_ptr content_; FormattedText caption_; @@ -325,9 +338,9 @@ class StoryManager final : public Actor { void unregister_story_global_id(const Story *story); - td_api::object_ptr get_story_info_object(StoryFullId story_full_id) const; + StoryInfo get_story_info(StoryFullId story_full_id) const; - td_api::object_ptr get_story_info_object(StoryFullId story_full_id, const Story *story) const; + td_api::object_ptr get_story_info_object(StoryFullId story_full_id) const; td_api::object_ptr get_story_object(StoryFullId story_full_id, const Story *story) const;