...Человеческий поиск в разработке...
- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/classes/general/restactivity.php
- Класс: CBPRestActivity
- Вызов: CBPRestActivity::execute
public function execute() { $activityData = static::getRestActivityData(); if (!$activityData) { throw new Exception(Loc::getMessage('BPRA_NOT_FOUND_ERROR')); } if (!Loader::includeModule('rest') || !BitrixRestOAuthService::getEngine()->isRegistered()) { return CBPActivityExecutionStatus::Closed; } $properties = $activityData['PROPERTIES']; $propertiesValues = []; if (!empty($properties)) { /** @var CBPDocumentService $documentService */ $documentService = $this->workflow->GetService('DocumentService'); foreach ($properties as $name => $property) { $property = static::normalizeProperty($property); $properties[$name] = $property; $propertiesValues[$name] = $this->__get($name); if ($propertiesValues[$name]) { $fieldTypeObject = $documentService->getFieldTypeObject($this->GetDocumentType(), $property); if ($fieldTypeObject) { $fieldTypeObject->setDocumentId($this->GetDocumentId()); $propertiesValues[$name] = $fieldTypeObject->externalizeValue( $this->GetName(), $propertiesValues[$name] ); } } if ($propertiesValues[$name] === null) { $propertiesValues[$name] = ''; } } if ($this->workflow->isDebug()) { $map = $this->getDebugInfo( $propertiesValues, $properties ); $this->writeDebugInfo($map); } } $dbRes = BitrixRestAppTable::getList([ 'filter' => [ '=CLIENT_ID' => $activityData['APP_ID'], ], ]); $application = $dbRes->fetch(); if (!$application) { throw new Exception('Rest application not found.'); } $appStatus = BitrixRestAppTable::getAppStatusInfo($application, ''); if ($appStatus['PAYMENT_ALLOW'] === 'N') { throw new Exception('Rest application status error: payment required'); } $userId = CBPHelper::ExtractUsers($this->AuthUserId, $this->GetDocumentId(), true); if (empty($userId) && !empty($activityData['AUTH_USER_ID'])) { $userId = $activityData['AUTH_USER_ID']; } $auth = [ 'WORKFLOW_ID' => $this->getWorkflowInstanceId(), 'ACTIVITY_NAME' => $this->name, 'CODE' => $activityData['CODE'], BitrixRestOAuthAuth::PARAM_LOCAL_USER => $userId, "application_token" => CRestUtil::getApplicationToken($application), ]; $this->eventId = BitrixMainSecurityRandom::getString(32, true); $queryItems = [ Sqs::queryItem( $activityData['APP_ID'], $activityData['HANDLER'], [ 'workflow_id' => $this->getWorkflowInstanceId(), 'code' => $activityData['CODE'], 'document_id' => $this->GetDocumentId(), 'document_type' => $this->GetDocumentType(), 'event_token' => self::generateToken($this->getWorkflowInstanceId(), $this->name, $this->eventId), 'properties' => $propertiesValues, 'use_subscription' => $this->UseSubscription, 'timeout_duration' => $this->CalculateTimeoutDuration(), 'ts' => time(), ], $auth, [ "sendAuth" => true, "sendRefreshToken" => true, "category" => Sqs::CATEGORY_BIZPROC, ] ), ]; BitrixRestOAuthService::getEngine()->getClient()->sendEvent($queryItems); if (is_callable(['BitrixRestUsageStatTable', 'logRobot'])) { if ($activityData['IS_ROBOT'] === 'Y') { BitrixRestUsageStatTable::logRobot($activityData['APP_ID'], $activityData['CODE']); } else { BitrixRestUsageStatTable::logActivity($activityData['APP_ID'], $activityData['CODE']); } BitrixRestUsageStatTable::finalize(); } if ($this->SetStatusMessage === 'Y') { $message = $this->StatusMessage; if (empty($message)) { $message = Loc::getMessage('BPRA_DEFAULT_STATUS_MESSAGE'); } $this->SetStatusTitle($message); } if ($this->UseSubscription !== 'Y') { return CBPActivityExecutionStatus::Closed; } $this->Subscribe($this); return CBPActivityExecutionStatus::Executing; }