Add storyViewers.total_count.

This commit is contained in:
levlam 2023-08-07 20:49:31 +03:00
parent 3bc3ef3335
commit c926b59053
4 changed files with 12 additions and 8 deletions

View File

@ -4938,8 +4938,11 @@ messageLinkInfo is_public:Bool chat_id:int53 message_thread_id:int53 message:mes
//@chosen_reaction_type Type of the reaction that was chosen by the user; may be null if none
storyViewer user_id:int53 view_date:int32 block_list:BlockList chosen_reaction_type:ReactionType = StoryViewer;
//@description Represents a list of story viewers @viewers List of story viewers @next_offset The offset for the next request. If empty, there are no more results
storyViewers viewers:vector<storyViewer> next_offset:string = StoryViewers;
//@description Represents a list of story viewers
//@total_count Approximate total number of story viewers found
//@viewers List of story viewers
//@next_offset The offset for the next request. If empty, there are no more results
storyViewers total_count:int32 viewers:vector<storyViewer> next_offset:string = StoryViewers;
//@description Describes position of a clickable rectangle area on a story media

View File

@ -2385,7 +2385,7 @@ void StoryManager::on_get_story_viewers(
total_count = static_cast<int32>(view_list->views_.size());
}
StoryViewers story_viewers(std::move(view_list->views_), std::move(view_list->next_offset_));
StoryViewers story_viewers(total_count, std::move(view_list->views_), std::move(view_list->next_offset_));
if (story->content_ != nullptr) {
bool is_changed = false;
if (is_full && story->interaction_info_.set_counts(view_list->count_, view_list->reactions_count_)) {

View File

@ -25,9 +25,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const StoryViewer &view
return string_builder << '[' << viewer.user_id_ << " with " << viewer.reaction_type_ << " at " << viewer.date_ << ']';
}
StoryViewers::StoryViewers(vector<telegram_api::object_ptr<telegram_api::storyView>> &&story_views,
StoryViewers::StoryViewers(int32 total_count, vector<telegram_api::object_ptr<telegram_api::storyView>> &&story_views,
string &&next_offset)
: next_offset_(std::move(next_offset)) {
: total_count_(total_count), next_offset_(std::move(next_offset)) {
for (auto &story_view : story_views) {
story_viewers_.emplace_back(std::move(story_view));
auto user_id = story_viewers_.back().get_user_id();
@ -45,6 +45,7 @@ vector<UserId> StoryViewers::get_user_ids() const {
td_api::object_ptr<td_api::storyViewers> StoryViewers::get_story_viewers_object(
ContactsManager *contacts_manager) const {
return td_api::make_object<td_api::storyViewers>(
total_count_,
transform(story_viewers_,
[contacts_manager](const StoryViewer &story_viewer) {
return story_viewer.get_story_viewer_object(contacts_manager);

View File

@ -46,15 +46,15 @@ class StoryViewer {
StringBuilder &operator<<(StringBuilder &string_builder, const StoryViewer &viewer);
class StoryViewers {
int32 total_count_ = 0;
vector<StoryViewer> story_viewers_;
string next_offset_;
friend StringBuilder &operator<<(StringBuilder &string_builder, const StoryViewers &viewers);
public:
StoryViewers() = default;
StoryViewers(vector<telegram_api::object_ptr<telegram_api::storyView>> &&story_views, string &&next_offset);
StoryViewers(int32 total_count, vector<telegram_api::object_ptr<telegram_api::storyView>> &&story_views,
string &&next_offset);
vector<UserId> get_user_ids() const;