• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/queue/event/all.php
  • Класс: BitrixImOpenLinesQueueEventAll
  • Вызов: All::returnNotAcceptedSessionsToQueue
public function returnNotAcceptedSessionsToQueue($userId = 0, string $reasonReturn = ImOpenLinesQueue::REASON_DEFAULT): void
{
	$sessionListManager = SessionTable::getList([
		'select' => [
			'ID',
			'OPERATOR_ID'
		],
		'filter' => [
			'LOGIC' => 'OR',
			[
				// Remove unanswered, but accepted by the operator dialogs.
				'=CONFIG_ID' => $this->configLine['ID'],
				'=OPERATOR_ID' => $userId,
				' Session::STATUS_OPERATOR,
				'!=PAUSE' => 'Y'
			],
			[
				// Rebuilding the list of missed conversations for operators.
				'=CONFIG_ID' => $this->configLine['ID'],
				' Session::STATUS_ANSWER,
				'!=OPERATOR_FROM_CRM' => 'Y'
			]
		]
	]);

	while ($session = $sessionListManager->fetch())
	{
		if (!empty($session['OPERATOR_ID']) && $session['OPERATOR_ID'] == $userId)
		{
			ImOpenLinesQueue::returnSessionToQueue($session['ID'], $reasonReturn);
		}
		else
		{
			ImOpenLinesQueue::returnSessionToQueue($session['ID']);
		}
	}
}