diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index b30283b2f..8dd533116 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3306,9 +3306,10 @@ 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 +//@forward_count Number of times the story was forwarded; 0 if none or unknown +//@reaction_count Number of reactions added to the story; 0 if none or unknown //@recent_viewer_user_ids Identifiers of at most 3 recent viewers of the story -storyInteractionInfo view_count:int32 reaction_count:int32 recent_viewer_user_ids:vector = StoryInteractionInfo; +storyInteractionInfo view_count:int32 forward_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 6f1e620e3..963629195 100644 --- a/td/telegram/StoryInteractionInfo.cpp +++ b/td/telegram/StoryInteractionInfo.cpp @@ -36,6 +36,11 @@ StoryInteractionInfo::StoryInteractionInfo(Td *td, telegram_api::object_ptrforwards_count_; + if (forward_count_ < 0) { + LOG(ERROR) << "Receive " << forward_count_ << " story forwards"; + forward_count_ = 0; + } reaction_count_ = story_views->reactions_count_; if (reaction_count_ < 0) { LOG(ERROR) << "Receive " << reaction_count_ << " story reactions"; @@ -75,18 +80,19 @@ td_api::object_ptr StoryInteractionInfo::get_story return nullptr; } return td_api::make_object( - view_count_, reaction_count_, + view_count_, forward_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_ && - lhs.reaction_count_ == rhs.reaction_count_ && lhs.has_viewers_ == rhs.has_viewers_; + lhs.forward_count_ == rhs.forward_count_ && lhs.reaction_count_ == rhs.reaction_count_ && + lhs.has_viewers_ == rhs.has_viewers_; } StringBuilder &operator<<(StringBuilder &string_builder, const StoryInteractionInfo &info) { - return string_builder << info.view_count_ << " views with " << info.reaction_count_ << " reactions by " - << info.recent_viewer_user_ids_; + return string_builder << info.view_count_ << " views and " << info.forward_count_ << " forwards 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 abf8529a6..5bbbc8dc4 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 forward_count_ = 0; int32 reaction_count_ = 0; bool has_viewers_ = false; diff --git a/td/telegram/StoryInteractionInfo.hpp b/td/telegram/StoryInteractionInfo.hpp index 112010298..46c298b06 100644 --- a/td/telegram/StoryInteractionInfo.hpp +++ b/td/telegram/StoryInteractionInfo.hpp @@ -19,11 +19,13 @@ void StoryInteractionInfo::store(StorerT &storer) const { bool has_recent_viewer_user_ids = !recent_viewer_user_ids_.empty(); bool has_reaction_count = reaction_count_ > 0; bool know_has_viewers = true; + bool has_forward_count = forward_count_ > 0; BEGIN_STORE_FLAGS(); STORE_FLAG(has_recent_viewer_user_ids); STORE_FLAG(has_reaction_count); STORE_FLAG(know_has_viewers); STORE_FLAG(has_viewers_); + STORE_FLAG(has_forward_count); END_STORE_FLAGS(); store(view_count_, storer); if (has_recent_viewer_user_ids) { @@ -32,6 +34,9 @@ void StoryInteractionInfo::store(StorerT &storer) const { if (has_reaction_count) { store(reaction_count_, storer); } + if (has_forward_count) { + store(forward_count_, storer); + } } template @@ -40,11 +45,13 @@ void StoryInteractionInfo::parse(ParserT &parser) { bool has_recent_viewer_user_ids; bool has_reaction_count; bool know_has_viewers; + bool has_forward_count; BEGIN_PARSE_FLAGS(); PARSE_FLAG(has_recent_viewer_user_ids); PARSE_FLAG(has_reaction_count); PARSE_FLAG(know_has_viewers); PARSE_FLAG(has_viewers_); + PARSE_FLAG(has_forward_count); END_PARSE_FLAGS(); parse(view_count_, parser); if (has_recent_viewer_user_ids) { @@ -53,6 +60,10 @@ void StoryInteractionInfo::parse(ParserT &parser) { if (has_reaction_count) { parse(reaction_count_, parser); } + if (has_forward_count) { + parse(forward_count_, parser); + } + if (!know_has_viewers) { has_viewers_ = (view_count_ > 0 && !has_recent_viewer_user_ids) || reaction_count_ > 0; }