From 288666c1feddb9a2a91cd4bea5c1d818b5ff913c Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 7 Jul 2023 17:41:30 +0300 Subject: [PATCH] Load all read stories from time to time. --- td/telegram/StoryManager.cpp | 26 ++++++++++++++++++++++++++ td/telegram/StoryManager.h | 2 ++ td/telegram/UpdatesManager.cpp | 1 + 3 files changed, 29 insertions(+) diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index be466839e..355e99288 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -123,6 +123,28 @@ class ToggleStoriesHiddenQuery final : public Td::ResultHandler { } }; +class GetAllReadUserStoriesQuery final : public Td::ResultHandler { + public: + void send() { + send_query(G()->net_query_creator().create(telegram_api::stories_getAllReadUserStories())); + } + + void on_result(BufferSlice packet) final { + auto result_ptr = fetch_result(packet); + if (result_ptr.is_error()) { + return on_error(result_ptr.move_as_error()); + } + + auto ptr = result_ptr.move_as_ok(); + LOG(DEBUG) << "Receive result for GetAllReadUserStoriesQuery: " << to_string(ptr); + td_->updates_manager_->on_get_updates(std::move(ptr), Promise()); + } + + void on_error(Status status) final { + LOG(INFO) << "Failed to get all read user stories: " << status; + } +}; + class ToggleAllStoriesHiddenQuery final : public Td::ResultHandler { Promise promise_; @@ -1104,6 +1126,10 @@ void StoryManager::on_load_active_stories( set_promises(promises); } +void StoryManager::reload_all_read_stories() { + td_->create_handler()->send(); +} + void StoryManager::try_synchronize_archive_all_stories() { if (G()->close_flag()) { return; diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index e5023445e..f5aaf6f50 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -158,6 +158,8 @@ class StoryManager final : public Actor { void reload_active_stories(); + void reload_all_read_stories(); + void toggle_dialog_stories_hidden(DialogId dialog_id, bool are_hidden, Promise &&promise); void get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId from_story_id, int32 limit, diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 2ee03cca8..b5290b716 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -2171,6 +2171,7 @@ void UpdatesManager::try_reload_data() { td_->stickers_manager_->get_default_dialog_photo_custom_emoji_stickers(false, true, Auto()); td_->stickers_manager_->get_default_dialog_photo_custom_emoji_stickers(true, true, Auto()); td_->story_manager_->reload_active_stories(); + td_->story_manager_->reload_all_read_stories(); schedule_data_reload(); }