From 40d11e79359ccd64cce08c4e7a532969454803e6 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 28 Jun 2023 18:23:40 +0300 Subject: [PATCH] Show changelog stories in story lists. --- td/telegram/StoryManager.cpp | 17 ++++++++++++----- td/telegram/StoryManager.h | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index fc6c5df93..3877f9aeb 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -1476,14 +1476,13 @@ td_api::object_ptr StoryManager::get_story_object(StoryFullId sto } auto story_id = story_full_id.get_story_id(); - auto changelog_user_id = td_->option_manager_->get_option_integer( - "stories_changelog_user_id", ContactsManager::get_service_notifications_user_id().get()); - bool is_visible_only_for_self = !story_id.is_server() || dialog_id == DialogId(changelog_user_id) || - (!story->is_pinned_ && !is_active_story(story)); + auto changelog_dialog_id = get_changelog_story_dialog_id(); + bool is_visible_only_for_self = + !story_id.is_server() || dialog_id == changelog_dialog_id || (!story->is_pinned_ && !is_active_story(story)); bool can_be_forwarded = !story->noforwards_ && story_id.is_server() && privacy_rules != nullptr && privacy_rules->rules_.size() == 1u && privacy_rules->rules_[0]->get_id() == td_api::userPrivacySettingRuleAllowAll::ID; - bool can_be_replied = story_id.is_server() && dialog_id != DialogId(changelog_user_id); + bool can_be_replied = story_id.is_server() && dialog_id != changelog_dialog_id; story->is_update_sent_ = true; @@ -1995,7 +1994,15 @@ bool StoryManager::on_update_read_stories(DialogId owner_dialog_id, StoryId max_ return false; } +DialogId StoryManager::get_changelog_story_dialog_id() const { + return DialogId(UserId(td_->option_manager_->get_option_integer( + "stories_changelog_user_id", ContactsManager::get_service_notifications_user_id().get()))); +} + bool StoryManager::is_subscribed_to_dialog_stories(DialogId owner_dialog_id) const { + if (owner_dialog_id == get_changelog_story_dialog_id()) { + return true; + } switch (owner_dialog_id.get_type()) { case DialogType::User: return td_->contacts_manager_->is_user_contact(owner_dialog_id.get_user_id()); diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index 9ecefb85a..8d1fb02cf 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -226,6 +226,8 @@ class StoryManager final : public Actor { static bool is_active_story(const Story *story); + DialogId get_changelog_story_dialog_id() const; + bool is_subscribed_to_dialog_stories(DialogId owner_dialog_id) const; const Story *get_story(StoryFullId story_full_id) const;