• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/recent.php
  • Класс: BitrixImRecent
  • Вызов: Recent::isUnread
static function isUnread(int $userId, string $itemType, string $dialogId): bool
{
	$id = mb_strpos($dialogId, 'chat') === 0 ? mb_substr($dialogId, 4) : $dialogId;
	$element = BitrixImModelRecentTable::getList([
		'select' => ['USER_ID', 'ITEM_TYPE', 'ITEM_ID', 'UNREAD', 'MUTED' => 'RELATION.NOTIFY_BLOCK', 'ITEM_CID'],
		'filter' => [
			'=USER_ID' => $userId,
			'=ITEM_TYPE' => $itemType,
			'=ITEM_ID' => $id
		]
	])->fetch();
	if (!$element)
	{
		return false;
	}

	return ($element['UNREAD'] ?? 'N') === 'Y';
}