• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/MessageCollection.php
  • Класс: BitrixImV2MessageCollection
  • Вызов: MessageCollection::fillViewed
public function fillViewed(): self
{
	if ($this->isViewedFilled)
	{
		return $this;
	}

	$notOwnMessages = [];

	foreach ($this as $message)
	{
		if ($message->getAuthorId() === $this->getContext()->getUserId())
		{
			$message->setViewed(true);

			continue;
		}

		$notOwnMessages[] = $message->getMessageId();
	}

	$viewStatuses = (new ReadService())->getViewStatusesByMessageIds($notOwnMessages);

	foreach ($notOwnMessages as $notOwnMessageId)
	{
		$this[$notOwnMessageId]->setViewed($viewStatuses[$notOwnMessageId]);
	}

	$this->isViewedFilled = true;

	return $this;
}