Add MessageViewers::get_sublist.
This commit is contained in:
parent
c9cd221d77
commit
2bf612c020
@ -22,6 +22,14 @@ td_api::object_ptr<td_api::messageViewer> MessageViewer::get_message_viewer_obje
|
||||
contacts_manager->get_user_id_object(user_id_, "get_message_viewer_object"), date_);
|
||||
}
|
||||
|
||||
bool operator==(const MessageViewer &lhs, const MessageViewer &rhs) {
|
||||
return lhs.user_id_ == rhs.user_id_ && lhs.date_ == rhs.date_;
|
||||
}
|
||||
|
||||
bool operator!=(const MessageViewer &lhs, const MessageViewer &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const MessageViewer &viewer) {
|
||||
return string_builder << '[' << viewer.user_id_ << " at " << viewer.date_ << ']';
|
||||
}
|
||||
@ -44,6 +52,22 @@ MessageViewers::MessageViewers(vector<telegram_api::object_ptr<telegram_api::rea
|
||||
})) {
|
||||
}
|
||||
|
||||
MessageViewers MessageViewers::get_sublist(const MessageViewer &offset, int32 limit) const {
|
||||
MessageViewers result{vector<telegram_api::object_ptr<telegram_api::storyView>>()};
|
||||
bool found = offset == MessageViewer(UserId(), 0);
|
||||
for (auto &message_viewer : message_viewers_) {
|
||||
if (found) {
|
||||
if (limit-- <= 0) {
|
||||
break;
|
||||
}
|
||||
result.message_viewers_.push_back(message_viewer);
|
||||
} else if (message_viewer == offset) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::messageViewers> MessageViewers::get_message_viewers_object(
|
||||
ContactsManager *contacts_manager) const {
|
||||
return td_api::make_object<td_api::messageViewers>(
|
||||
|
@ -23,6 +23,8 @@ class MessageViewer {
|
||||
|
||||
friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageViewer &viewer);
|
||||
|
||||
friend bool operator==(const MessageViewer &lhs, const MessageViewer &rhs);
|
||||
|
||||
public:
|
||||
explicit MessageViewer(telegram_api::object_ptr<telegram_api::readParticipantDate> &&read_date);
|
||||
|
||||
@ -36,6 +38,10 @@ class MessageViewer {
|
||||
td_api::object_ptr<td_api::messageViewer> get_message_viewer_object(ContactsManager *contacts_manager) const;
|
||||
};
|
||||
|
||||
bool operator==(const MessageViewer &lhs, const MessageViewer &rhs);
|
||||
|
||||
bool operator!=(const MessageViewer &lhs, const MessageViewer &rhs);
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const MessageViewer &viewer);
|
||||
|
||||
struct MessageViewers {
|
||||
@ -45,6 +51,8 @@ struct MessageViewers {
|
||||
|
||||
explicit MessageViewers(vector<telegram_api::object_ptr<telegram_api::readParticipantDate>> &&read_dates);
|
||||
|
||||
MessageViewers get_sublist(const MessageViewer &offset, int32 limit) const;
|
||||
|
||||
td_api::object_ptr<td_api::messageViewers> get_message_viewers_object(ContactsManager *contacts_manager) const;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user