2023-08-07 15:03:10 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2023-08-07 15:03:10 +02:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
2023-12-25 14:32:41 +01:00
|
|
|
#include "td/telegram/DialogId.h"
|
2023-12-25 20:07:02 +01:00
|
|
|
#include "td/telegram/MessageFullId.h"
|
2023-08-07 16:19:12 +02:00
|
|
|
#include "td/telegram/ReactionType.h"
|
2023-12-25 20:07:02 +01:00
|
|
|
#include "td/telegram/StoryId.h"
|
2023-08-07 15:03:10 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
#include "td/telegram/UserId.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2023-12-25 13:52:03 +01:00
|
|
|
class Td;
|
2023-08-07 15:03:10 +02:00
|
|
|
|
|
|
|
class StoryViewer {
|
2023-12-25 20:07:02 +01:00
|
|
|
enum class Type : int32 { None, View, Forward, Repost };
|
|
|
|
Type type_ = Type::None;
|
|
|
|
|
|
|
|
DialogId actor_dialog_id_;
|
2023-08-07 15:03:10 +02:00
|
|
|
int32 date_ = 0;
|
2023-08-07 16:19:12 +02:00
|
|
|
bool is_blocked_ = false;
|
|
|
|
bool is_blocked_for_stories_ = false;
|
2023-12-25 20:07:02 +01:00
|
|
|
|
|
|
|
ReactionType reaction_type_; // for View
|
|
|
|
MessageFullId message_full_id_; // for Forward
|
|
|
|
StoryId story_id_; // for Repost
|
2023-08-07 15:03:10 +02:00
|
|
|
|
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const StoryViewer &viewer);
|
|
|
|
|
|
|
|
public:
|
2023-12-25 15:30:26 +01:00
|
|
|
StoryViewer(Td *td, telegram_api::object_ptr<telegram_api::StoryView> &&story_view_ptr);
|
2023-08-07 15:03:10 +02:00
|
|
|
|
2023-12-26 11:57:43 +01:00
|
|
|
StoryViewer(Td *td, telegram_api::object_ptr<telegram_api::StoryReaction> &&story_reaction_ptr);
|
|
|
|
|
2023-12-25 14:32:41 +01:00
|
|
|
UserId get_viewer_user_id() const {
|
2023-12-25 20:07:02 +01:00
|
|
|
return type_ == Type::View ? actor_dialog_id_.get_user_id() : UserId();
|
2023-08-07 15:03:10 +02:00
|
|
|
}
|
|
|
|
|
2023-12-25 14:32:41 +01:00
|
|
|
DialogId get_actor_dialog_id() const {
|
2023-12-25 20:07:02 +01:00
|
|
|
return actor_dialog_id_;
|
2023-12-25 14:32:41 +01:00
|
|
|
}
|
|
|
|
|
2023-12-25 14:34:38 +01:00
|
|
|
bool is_valid() const;
|
|
|
|
|
2023-12-25 20:07:02 +01:00
|
|
|
td_api::object_ptr<td_api::storyInteraction> get_story_interaction_object(Td *td) const;
|
2023-08-07 15:03:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const StoryViewer &viewer);
|
|
|
|
|
|
|
|
class StoryViewers {
|
2023-08-07 19:49:31 +02:00
|
|
|
int32 total_count_ = 0;
|
2023-12-25 13:10:48 +01:00
|
|
|
int32 total_forward_count_ = 0;
|
2023-08-16 12:45:10 +02:00
|
|
|
int32 total_reaction_count_ = 0;
|
2023-08-07 15:03:10 +02:00
|
|
|
vector<StoryViewer> story_viewers_;
|
2023-08-07 18:40:15 +02:00
|
|
|
string next_offset_;
|
2023-08-07 15:03:10 +02:00
|
|
|
|
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const StoryViewers &viewers);
|
|
|
|
|
|
|
|
public:
|
2023-12-25 13:52:03 +01:00
|
|
|
StoryViewers(Td *td, int32 total_count, int32 total_forward_count, int32 total_reaction_count,
|
2023-12-05 10:30:12 +01:00
|
|
|
vector<telegram_api::object_ptr<telegram_api::StoryView>> &&story_views, string &&next_offset);
|
2023-08-07 15:03:10 +02:00
|
|
|
|
2023-12-26 11:57:43 +01:00
|
|
|
StoryViewers(Td *td, int32 total_count,
|
|
|
|
vector<telegram_api::object_ptr<telegram_api::StoryReaction>> &&story_reactions, string &&next_offset);
|
|
|
|
|
2023-12-25 14:32:41 +01:00
|
|
|
vector<UserId> get_viewer_user_ids() const;
|
|
|
|
|
|
|
|
vector<DialogId> get_actor_dialog_ids() const;
|
2023-08-07 15:03:10 +02:00
|
|
|
|
2023-12-25 20:07:02 +01:00
|
|
|
td_api::object_ptr<td_api::storyInteractions> get_story_interactions_object(Td *td) const;
|
2023-08-07 15:03:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const StoryViewers &viewers);
|
|
|
|
|
|
|
|
} // namespace td
|