Add storyInteractionInfo.forward_count.

This commit is contained in:
levlam 2023-09-18 22:00:38 +03:00
parent 118358508a
commit fde0c8a0b1
4 changed files with 25 additions and 6 deletions

View File

@ -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<int53> = StoryInteractionInfo;
storyInteractionInfo view_count:int32 forward_count:int32 reaction_count:int32 recent_viewer_user_ids:vector<int53> = StoryInteractionInfo;
//@description Represents a story
//@id Unique story identifier among stories of the given sender

View File

@ -36,6 +36,11 @@ StoryInteractionInfo::StoryInteractionInfo(Td *td, telegram_api::object_ptr<tele
LOG(ERROR) << "Receive " << view_count_ << " story views";
view_count_ = 0;
}
forward_count_ = story_views->forwards_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<td_api::storyInteractionInfo> StoryInteractionInfo::get_story
return nullptr;
}
return td_api::make_object<td_api::storyInteractionInfo>(
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

View File

@ -21,6 +21,7 @@ class Td;
class StoryInteractionInfo {
vector<UserId> recent_viewer_user_ids_;
int32 view_count_ = -1;
int32 forward_count_ = 0;
int32 reaction_count_ = 0;
bool has_viewers_ = false;

View File

@ -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 <class ParserT>
@ -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;
}