Add storyInteractionInfo.reaction_count.
This commit is contained in:
parent
ea33e9f2d0
commit
6acd85411f
@ -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<int53> = StoryInteractionInfo;
|
||||
storyInteractionInfo view_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
|
||||
|
@ -36,6 +36,11 @@ StoryInteractionInfo::StoryInteractionInfo(Td *td, telegram_api::object_ptr<tele
|
||||
LOG(ERROR) << "Receive " << view_count_ << " story views";
|
||||
view_count_ = 0;
|
||||
}
|
||||
reaction_count_ = story_views->reactions_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<td_api::storyInteractionInfo> StoryInteractionInfo::get_story
|
||||
return nullptr;
|
||||
}
|
||||
return td_api::make_object<td_api::storyInteractionInfo>(
|
||||
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
|
||||
|
@ -21,6 +21,7 @@ class Td;
|
||||
class StoryInteractionInfo {
|
||||
vector<UserId> recent_viewer_user_ids_;
|
||||
int32 view_count_ = -1;
|
||||
int32 reaction_count_ = 0;
|
||||
|
||||
static constexpr size_t MAX_RECENT_VIEWERS = 3;
|
||||
|
||||
|
@ -17,26 +17,36 @@ template <class StorerT>
|
||||
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 <class ParserT>
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user