PingAgent::sendNotification

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. PingAgent
  4. sendNotification
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/agent/activity/pingagent.php
  • Класс: Bitrix\Crm\Agent\Activity\PingAgent
  • Вызов: PingAgent::sendNotification
static function sendNotification(int $ownerTypeId, int $ownerId, array $activity): void
{
	if (!Loader::includeModule('im'))
	{
		return;
	}

	if (empty($activity))
	{
		return;
	}

	$url = Container::getInstance()->getRouter()->getItemDetailUrl($ownerTypeId, $ownerId);
	if (!isset($url))
	{
		return;
	}

	$entityName = (string)$ownerId; // ID by default
	if (CCrmOwnerType::isUseFactoryBasedApproach($ownerTypeId))
	{
		$entityName = Container::getInstance()->getFactory($ownerTypeId)?->getItem($ownerId)?->getHeading();
	}

	$message = (new ProcessTodoActivity($ownerTypeId))
		->getMessage([
			'#subject#' => isset($activity['SUBJECT']) && mb_strlen($activity['SUBJECT']) > 0
				? htmlspecialcharsbx($activity['SUBJECT'])
				: '',
			'#url#' => '#url#',
			'#title#' => htmlspecialcharsbx(trim($entityName)),
			'#deadline#' => static::transformDateTime($activity['DEADLINE'] ?? null, $activity['RESPONSIBLE_ID'] ?? null),
		])
	;

	CIMNotify::Add([
		'MESSAGE_TYPE' => IM_MESSAGE_SYSTEM,
		'TO_USER_ID' => $activity['RESPONSIBLE_ID'] ?? null,
		'FROM_USER_ID' => $activity['AUTHOR_ID'] ?? null,
		'NOTIFY_TYPE' => IM_NOTIFY_FROM,
		'NOTIFY_MODULE' => 'crm',
		'NOTIFY_EVENT' => 'pingTodoActivity',
		'NOTIFY_TAG' => 'CRM|PING_TODO_ACTIVITY|' . $activity['ID'],
		'NOTIFY_MESSAGE' => str_replace('#url#', $url, $message),
		'NOTIFY_MESSAGE_OUT' => str_replace('#url#', static::transformRelativeUrlToAbsolute($url), $message),
	]);
}

Добавить комментарий