From f37a9e73ca92c2002cf828e418875ca5ff9b5389 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 4 Aug 2023 19:18:27 +0300 Subject: [PATCH] Support telegram_api::updateSentStoryReaction. --- td/telegram/StoryManager.cpp | 20 ++++++++++++++++++++ td/telegram/StoryManager.h | 3 +++ td/telegram/UpdatesManager.cpp | 6 ++++-- td/telegram/UpdatesManager.h | 4 ++-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/td/telegram/StoryManager.cpp b/td/telegram/StoryManager.cpp index ffcd369ea..62b9c7687 100644 --- a/td/telegram/StoryManager.cpp +++ b/td/telegram/StoryManager.cpp @@ -3272,6 +3272,26 @@ void StoryManager::on_update_story_stealth_mode( set_story_stealth_mode(StoryStealthMode(std::move(stealth_mode))); } +void StoryManager::on_update_story_chosen_reaction_type(DialogId owner_dialog_id, StoryId story_id, + ReactionType chosen_reaction_type) { + if (!owner_dialog_id.is_valid() || !story_id.is_server()) { + LOG(ERROR) << "Receive chosen reaction in " << story_id << " in " << owner_dialog_id; + return; + } + if (!td_->messages_manager_->have_dialog_info_force(owner_dialog_id)) { + return; + } + StoryFullId story_full_id{owner_dialog_id, story_id}; + Story *story = get_story_force(story_full_id, "on_update_story_chosen_reaction_type"); + if (story == nullptr) { + return; + } + if (story->chosen_reaction_type_ != chosen_reaction_type) { + story->chosen_reaction_type_ = std::move(chosen_reaction_type); + on_story_changed(story_full_id, story, true, true); + } +} + void StoryManager::set_story_stealth_mode(StoryStealthMode stealth_mode) { if (stealth_mode == stealth_mode_) { return; diff --git a/td/telegram/StoryManager.h b/td/telegram/StoryManager.h index 4a953b59a..5a1bfc098 100644 --- a/td/telegram/StoryManager.h +++ b/td/telegram/StoryManager.h @@ -268,6 +268,9 @@ class StoryManager final : public Actor { void on_update_story_stealth_mode(telegram_api::object_ptr &&stealth_mode); + void on_update_story_chosen_reaction_type(DialogId owner_dialog_id, StoryId story_id, + ReactionType chosen_reaction_type); + void on_dialog_active_stories_order_updated(DialogId owner_dialog_id, const char *source); Status can_get_story_viewers(StoryFullId story_full_id, const Story *story) const; diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index caef536ab..2cd58a749 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -4316,12 +4316,14 @@ void UpdatesManager::on_update(tl_object_ptr update, Promise &&promise) { + td_->story_manager_->on_update_story_chosen_reaction_type( + DialogId(UserId(update->user_id_)), StoryId(update->story_id_), ReactionType(update->reaction_)); promise.set_value(Unit()); } +// unsupported updates + void UpdatesManager::on_update(tl_object_ptr update, Promise &&promise) { promise.set_value(Unit()); } diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index b54b4487e..d4d5b465c 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -626,10 +626,10 @@ class UpdatesManager final : public Actor { void on_update(tl_object_ptr update, Promise &&promise); - // unsupported updates - void on_update(tl_object_ptr update, Promise &&promise); + // unsupported updates + void on_update(tl_object_ptr update, Promise &&promise); };