diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index f19dbeb04..121955cfd 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -5027,8 +5027,9 @@ storyListArchive = StoryList; //@description Contains information about interactions with a story //@view_count Number of times the story was viewed +//@reaction_count Number of reactions added to the story //@recent_viewer_user_ids Identifiers of at most 3 recent viewers of the story -storyInteractionInfo view_count:int32 recent_viewer_user_ids:vector = StoryInteractionInfo; +storyInteractionInfo view_count:int32 reaction_count:int32 recent_viewer_user_ids:vector = StoryInteractionInfo; //@description Represents a story //@id Unique story identifier among stories of the given sender diff --git a/td/telegram/StoryInteractionInfo.cpp b/td/telegram/StoryInteractionInfo.cpp index e5f6772e0..ed7b1e24d 100644 --- a/td/telegram/StoryInteractionInfo.cpp +++ b/td/telegram/StoryInteractionInfo.cpp @@ -36,6 +36,11 @@ StoryInteractionInfo::StoryInteractionInfo(Td *td, telegram_api::object_ptrreactions_count_; + if (reaction_count_ < 0) { + LOG(ERROR) << "Receive " << reaction_count_ << " story reactions"; + reaction_count_ = 0; + } } void StoryInteractionInfo::add_dependencies(Dependencies &dependencies) const { @@ -61,16 +66,18 @@ td_api::object_ptr StoryInteractionInfo::get_story return nullptr; } return td_api::make_object( - view_count_, + view_count_, reaction_count_, td->contacts_manager_->get_user_ids_object(recent_viewer_user_ids_, "get_story_interaction_info_object")); } bool operator==(const StoryInteractionInfo &lhs, const StoryInteractionInfo &rhs) { - return lhs.recent_viewer_user_ids_ == rhs.recent_viewer_user_ids_ && lhs.view_count_ == rhs.view_count_; + return lhs.recent_viewer_user_ids_ == rhs.recent_viewer_user_ids_ && lhs.view_count_ == rhs.view_count_ && + lhs.reaction_count_ == rhs.reaction_count_; } StringBuilder &operator<<(StringBuilder &string_builder, const StoryInteractionInfo &info) { - return string_builder << info.view_count_ << " views by " << info.recent_viewer_user_ids_; + return string_builder << info.view_count_ << " views with " << info.reaction_count_ << " reactions by " + << info.recent_viewer_user_ids_; } } // namespace td diff --git a/td/telegram/StoryInteractionInfo.h b/td/telegram/StoryInteractionInfo.h index 08b688950..6963f20e5 100644 --- a/td/telegram/StoryInteractionInfo.h +++ b/td/telegram/StoryInteractionInfo.h @@ -21,6 +21,7 @@ class Td; class StoryInteractionInfo { vector recent_viewer_user_ids_; int32 view_count_ = -1; + int32 reaction_count_ = 0; static constexpr size_t MAX_RECENT_VIEWERS = 3; diff --git a/td/telegram/StoryInteractionInfo.hpp b/td/telegram/StoryInteractionInfo.hpp index 9501d4b08..b47afef0d 100644 --- a/td/telegram/StoryInteractionInfo.hpp +++ b/td/telegram/StoryInteractionInfo.hpp @@ -17,26 +17,36 @@ template void StoryInteractionInfo::store(StorerT &storer) const { using td::store; bool has_recent_viewer_user_ids = !recent_viewer_user_ids_.empty(); + bool has_reaction_count = reaction_count_ > 0; BEGIN_STORE_FLAGS(); STORE_FLAG(has_recent_viewer_user_ids); + STORE_FLAG(has_reaction_count); END_STORE_FLAGS(); store(view_count_, storer); if (has_recent_viewer_user_ids) { store(recent_viewer_user_ids_, storer); } + if (has_reaction_count) { + store(reaction_count_, storer); + } } template void StoryInteractionInfo::parse(ParserT &parser) { using td::parse; bool has_recent_viewer_user_ids; + bool has_reaction_count; BEGIN_PARSE_FLAGS(); PARSE_FLAG(has_recent_viewer_user_ids); + PARSE_FLAG(has_reaction_count); END_PARSE_FLAGS(); parse(view_count_, parser); if (has_recent_viewer_user_ids) { parse(recent_viewer_user_ids_, parser); } + if (has_reaction_count) { + parse(reaction_count_, parser); + } } } // namespace td