• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Message/ViewedService.php
  • Класс: BitrixImV2MessageViewedService
  • Вызов: ViewedService::prepareInsertFields
private function prepareInsertFields(MessageCollection $messages): array
{
	$insertFields = [];
	$userId = $this->getContext()->getUserId();
	$dateCreate = new DateTime();

	foreach ($messages as $message)
	{
		if ($message->getAuthorId() === $userId && $message->getChat()->getType() !== IM_MESSAGE_SYSTEM)
		{
			continue;
		}
		$insertFields[] = [
			'USER_ID' => $userId,
			'CHAT_ID' => $message->getChatId(),
			'MESSAGE_ID' => $message->getMessageId(),
			'DATE_CREATE' => $dateCreate,
		];
	}

	return $insertFields;
}