Ensure that user_ids are valid in MessageViewers.

This commit is contained in:
levlam 2023-06-28 21:40:15 +03:00
parent 26a0d109c2
commit c157ffbfb5
2 changed files with 9 additions and 9 deletions

View File

@ -45,11 +45,15 @@ MessageViewers::MessageViewers(vector<telegram_api::object_ptr<telegram_api::sto
}
}
MessageViewers::MessageViewers(vector<telegram_api::object_ptr<telegram_api::readParticipantDate>> &&read_dates)
: message_viewers_(
transform(std::move(read_dates), [](telegram_api::object_ptr<telegram_api::readParticipantDate> &&read_date) {
return MessageViewer(std::move(read_date));
})) {
MessageViewers::MessageViewers(vector<telegram_api::object_ptr<telegram_api::readParticipantDate>> &&read_dates) {
for (auto &read_date : read_dates) {
message_viewers_.emplace_back(std::move(read_date));
auto user_id = message_viewers_.back().get_user_id();
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << user_id << " as a viewer of a message";
message_viewers_.pop_back();
}
}
}
MessageViewers MessageViewers::get_sublist(const MessageViewer &offset, int32 limit) const {

View File

@ -18201,10 +18201,6 @@ void MessagesManager::on_get_message_viewers(DialogId dialog_id, MessageViewers
if (!is_recursive) {
bool need_participant_list = false;
for (auto user_id : message_viewers.get_user_ids()) {
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << user_id << " as viewer of a message in " << dialog_id;
continue;
}
if (!td_->contacts_manager_->have_user_force(user_id)) {
need_participant_list = true;
}