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) MessageViewers::MessageViewers(vector<telegram_api::object_ptr<telegram_api::readParticipantDate>> &&read_dates) {
: message_viewers_( for (auto &read_date : read_dates) {
transform(std::move(read_dates), [](telegram_api::object_ptr<telegram_api::readParticipantDate> &&read_date) { message_viewers_.emplace_back(std::move(read_date));
return MessageViewer(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 { 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) { if (!is_recursive) {
bool need_participant_list = false; bool need_participant_list = false;
for (auto user_id : message_viewers.get_user_ids()) { 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)) { if (!td_->contacts_manager_->have_user_force(user_id)) {
need_participant_list = true; need_participant_list = true;
} }