• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/controller/sharingajax.php
  • Класс: BitrixCalendarControllerSharingAjax
  • Вызов: SharingAjax::handleTimelineNotifyAction
public function handleTimelineNotifyAction(): array
{
	$result = [];

	if (!Loader::includeModule('crm'))
	{
		$this->addError(new Error('Module crm not installed'));

		return $result;
	}

	$connection = Application::getConnection();
	$sqlHelper = $connection->getSqlHelper();
	$request = $this->getRequest();
	$linkHash = $sqlHelper->forSql(trim($request['linkHash'] ?? ''));
	$entityType = $sqlHelper->forSql(trim($request['entityType'] ?? ''));
	$notifyType = $sqlHelper->forSql(trim($request['notifyType']) ?? '');
	$entityId = (int)($request['entityId'] ?? null);
	$dateFrom = $request['dateFrom'] ?? null;
	$timezone = $request['timezone'] ?? null;


	/** @var SharingLinkCrmDealLink $link */
	$link = $this->getSharingLinkFactory()->getLinkByHash($linkHash);
	if (
		!$link
		|| !$link->isActive()
		|| $link->getObjectId() !== $entityId
		|| $link->getObjectType() !== $entityType
	)
	{
		$this->addError(new Error('Link not found'));

		return $result;
	}

	if (in_array($notifyType, SharingCrmNotifyManager::NOTIFY_TYPES, true))
	{
		(new SharingCrmNotifyManager($link, $notifyType))
			->sendSharedCrmActionsEvent(Util::getDateTimestamp($dateFrom, $timezone));

		$link->setLastStatus($notifyType);
		(new SharingLinkCrmDealLinkMapper())->update($link);
	}

	return $result;
}