2023-02-23 13:15:10 +01:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
|
|
|
|
class ContactsManager;
|
|
|
|
|
|
|
|
class MessageViewer {
|
|
|
|
UserId user_id_;
|
|
|
|
int32 date_ = 0;
|
|
|
|
|
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageViewer &viewer);
|
|
|
|
|
2023-06-19 17:45:56 +02:00
|
|
|
friend bool operator==(const MessageViewer &lhs, const MessageViewer &rhs);
|
|
|
|
|
2023-02-23 13:15:10 +01:00
|
|
|
public:
|
|
|
|
explicit MessageViewer(telegram_api::object_ptr<telegram_api::readParticipantDate> &&read_date);
|
|
|
|
|
2023-06-18 22:25:50 +02:00
|
|
|
MessageViewer(UserId user_id, int32 date) : user_id_(user_id), date_(td::max(date, static_cast<int32>(0))) {
|
|
|
|
}
|
|
|
|
|
2023-02-23 13:15:10 +01:00
|
|
|
UserId get_user_id() const {
|
|
|
|
return user_id_;
|
|
|
|
}
|
|
|
|
|
2023-06-20 13:48:51 +02:00
|
|
|
bool is_empty() const {
|
|
|
|
return user_id_ == UserId() && date_ == 0;
|
|
|
|
}
|
|
|
|
|
2023-02-23 13:15:10 +01:00
|
|
|
td_api::object_ptr<td_api::messageViewer> get_message_viewer_object(ContactsManager *contacts_manager) const;
|
|
|
|
};
|
|
|
|
|
2023-06-19 17:45:56 +02:00
|
|
|
bool operator==(const MessageViewer &lhs, const MessageViewer &rhs);
|
|
|
|
|
|
|
|
bool operator!=(const MessageViewer &lhs, const MessageViewer &rhs);
|
|
|
|
|
2023-02-23 13:15:10 +01:00
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const MessageViewer &viewer);
|
|
|
|
|
|
|
|
struct MessageViewers {
|
|
|
|
vector<MessageViewer> message_viewers_;
|
|
|
|
|
2023-06-20 14:54:47 +02:00
|
|
|
MessageViewers() = default;
|
|
|
|
|
2023-06-18 22:25:50 +02:00
|
|
|
explicit MessageViewers(vector<telegram_api::object_ptr<telegram_api::storyView>> &&story_views);
|
|
|
|
|
2023-02-23 13:15:10 +01:00
|
|
|
explicit MessageViewers(vector<telegram_api::object_ptr<telegram_api::readParticipantDate>> &&read_dates);
|
|
|
|
|
2023-06-20 14:54:47 +02:00
|
|
|
bool is_empty() const {
|
|
|
|
return message_viewers_.empty();
|
|
|
|
}
|
|
|
|
|
2023-06-19 17:45:56 +02:00
|
|
|
MessageViewers get_sublist(const MessageViewer &offset, int32 limit) const;
|
|
|
|
|
2023-06-20 14:54:47 +02:00
|
|
|
void add_sublist(const MessageViewer &offset, const MessageViewers &sublist);
|
|
|
|
|
2023-06-20 15:12:12 +02:00
|
|
|
vector<UserId> get_user_ids() const;
|
|
|
|
|
2023-02-23 13:15:10 +01:00
|
|
|
td_api::object_ptr<td_api::messageViewers> get_message_viewers_object(ContactsManager *contacts_manager) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const MessageViewers &viewers);
|
|
|
|
|
|
|
|
} // namespace td
|