• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Message/CounterService.php
  • Класс: BitrixImV2MessageCounterService
  • Вызов: CounterService::getForEachChat
public function getForEachChat(?array $chatIds = null): array
{
	$userId = $this->getContext()->getUserId();
	if (isset(self::$staticChatsCounterCache[$userId]))
	{
		return self::$staticChatsCounterCache[$userId];
	}

	$cache = $this->getCacheForChatsCounters();
	$cachedCounters = $cache->getVars();
	if ($cachedCounters !== false)
	{
		self::$staticChatsCounterCache[$userId] = $cachedCounters;

		return $cachedCounters;
	}

	$this->counters = static::DEFAULT_COUNTERS;
	$this->countersByChatIds = [];

	$this->countUnreadMessages($chatIds);

	if ($chatIds === null)
	{
		$this->saveChatsCountersInCache($cache);
	}

	return $this->countersByChatIds;
}