From 0f9f38050958cd3fc5be0a50d7d24f612d621a6d Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 22 Jun 2023 21:40:34 +0300 Subject: [PATCH] Reload opened stories once a minute. --- td/telegram/StoryManager.cpp | 6 ++++++ td/telegram/StoryManager.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index 32c0e4384..976d7c7ad 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -964,6 +964,10 @@ void StoryManager::open_story(DialogId owner_dialog_id, StoryId story_id, Promis return promise.set_value(Unit()); } + if (story_id.is_server() && story->receive_date_ < G()->unix_time() - OPENED_STORY_POLL_PERIOD) { + reload_story(story_full_id, Auto()); + } + for (auto file_id : get_story_file_ids(story)) { td_->file_manager_->check_local_location_async(file_id, true); } @@ -1458,6 +1462,8 @@ StoryId StoryManager::on_get_story(DialogId owner_dialog_id, } CHECK(story != nullptr); + story->receive_date_ = G()->unix_time(); + bool is_bot = td_->auth_manager_->is_bot(); auto caption = get_message_text(td_->contacts_manager_.get(), std::move(story_item->caption_), std::move(story_item->entities_), diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index 032077e75..b5ef296b6 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -42,6 +42,7 @@ class StoryManager final : public Actor { struct Story { int32 date_ = 0; int32 expire_date_ = 0; + int32 receive_date_ = 0; bool is_pinned_ = false; bool is_public_ = false; bool is_for_close_friends_ = false; @@ -188,6 +189,8 @@ class StoryManager final : public Actor { class DeleteStoryOnServerLogEvent; class ReadStoriesOnServerLogEvent; + static constexpr int32 OPENED_STORY_POLL_PERIOD = 60; + void start_up() final; void tear_down() final;