From 7bea5721bfa84d095605b6f979ee6dde62fdff2b Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 1 Jun 2023 13:55:11 +0300 Subject: [PATCH] Add updateStory. --- td/generate/scheme/td_api.tl | 3 +++ td/telegram/StoryManager.cpp | 8 ++++++-- td/telegram/StoryManager.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0a865c3f7..9bb77c80f 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -5636,6 +5636,9 @@ updateUnreadMessageCount chat_list:ChatList unread_count:int32 unread_unmuted_co //@marked_as_unread_unmuted_count Total number of unmuted chats marked as unread updateUnreadChatCount chat_list:ChatList total_count:int32 unread_count:int32 unread_unmuted_count:int32 marked_as_unread_count:int32 marked_as_unread_unmuted_count:int32 = Update; +//@description A story was changed @story The new information about the story +updateStory story:story = Update; + //@description An option changed its value @name The option name @value The new option value updateOption name:string value:OptionValue = Update; diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index 512ecdb21..eb8604f89 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -458,6 +458,7 @@ td_api::object_ptr StoryManager::get_story_object(StoryFullId sto if (story == nullptr) { return nullptr; } + story->is_update_sent_ = true; auto dialog_id = story_full_id.get_dialog_id(); bool is_owned = is_story_owned(dialog_id); if (!is_owned && !story->is_pinned_ && G()->unix_time() >= story->expire_date_) { @@ -606,8 +607,9 @@ void StoryManager::on_story_changed(StoryFullId story_full_id, const Story *stor if (is_changed || need_save_to_database) { // save_story(story, story_id); - if (is_changed) { - // send_closure(G()->td(), &Td::send_update, td_api::make_object(get_story_object(story_full_id, story))); + if (is_changed && story->is_update_sent_) { + send_closure(G()->td(), &Td::send_update, + td_api::make_object(get_story_object(story_full_id, story))); } } } @@ -863,6 +865,8 @@ void StoryManager::edit_story(StoryId story_id, td_api::object_ptr::max() - (++send_story_count_), story->edit_generation_, std::move(new_story)); + on_story_changed(story_full_id, story, true, true); + if (edited_story->content_ == nullptr) { return do_edit_story(FileId(), std::move(pending_story), nullptr); } diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index 9016ab14c..267ae8982 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -37,6 +37,7 @@ class StoryManager final : public Actor { bool is_pinned_ = false; bool is_public_ = false; bool is_for_close_friends_ = false; + mutable bool is_update_sent_ = false; // whether the story is known to the app StoryInteractionInfo interaction_info_; UserPrivacySettingRules privacy_rules_; unique_ptr content_;