81 public static function unbind($moduleId, $eventName)
84 $eventManager->unRegisterEventHandler($moduleId, $eventName,
"rest",
"\\Bitrix\\Rest\\Event\\Callback", static::getHandlerName($moduleId, $eventName));
87 $eventManager->unRegisterEventHandler($moduleId, $eventName,
"rest",
"CRestEventCallback", static::getHandlerName($moduleId, $eventName));
110 public static function getAuth($appId, $userId, array $additionalData = array(), array $additional = array())
114 $application = AppTable::getByClientId($appId);
117 if($userId > 0 && $additional[
"sendAuth"])
119 if(OAuthService::getEngine()->isRegistered())
121 $auth = Application::getAuthProvider()->get($application[
'CLIENT_ID'], $application[
'SCOPE'], $additionalData, $userId);
123 if(is_array($auth) && !$additional[
"sendRefreshToken"])
125 unset($auth[
'refresh_token']);
134 "member_id" => \CRestUtil::getMemberId()
138 $auth[
"application_token"] = \CRestUtil::getApplicationToken($application);
153 public static function call($handlersList)
157 $offlineEvents = array();
158 $logger = LoggerManager::getInstance()->getLogger();
163 .
"{date} - {host}\n{delimiter}\n"
164 .
" Sender::call() starts.\n"
165 .
"{handlersList}\n{delimiter} ",
167 'handlersList' => $handlersList,
172 foreach($handlersList as $handlerInfo)
174 $handler = $handlerInfo[0];
175 $data = $handlerInfo[1];
176 $additional = $handlerInfo[2];
178 foreach(static::$defaultEventParams as $key => $value)
180 if(!isset($additional[$key]))
182 $additional[$key] = $value;
193 .
"{date} - {host}\n{delimiter}\n"
194 .
"Session ttl exceeded {session}.\n",
196 'session' => $session,
205 $userId = $handler[
'USER_ID'] > 0
206 ? $handler[
'USER_ID']
209 is_object($USER) && $USER->isAuthorized()
215 if($handler[
'APP_ID'] > 0)
217 $dbRes = AppTable::getById($handler[
'APP_ID']);
218 $application = $dbRes->fetch();
220 $appStatus = \Bitrix\Rest\AppTable::getAppStatusInfo($application,
'');
221 if($appStatus[
'PAYMENT_ALLOW'] ===
'Y')
224 Session::PARAM_SESSION => $session,
225 Auth::PARAM_LOCAL_USER => $userId,
226 "application_token" => \CRestUtil::getApplicationToken($application),
230 if($handler[
'EVENT_HANDLER'] <>
'')
232 UsageStatTable::logEvent($application[
'CLIENT_ID'], $handler[
'EVENT_NAME']);
237 $application = array(
'CLIENT_ID' =>
null);
240 Session::PARAM_SESSION => $session,
241 Auth::PARAM_LOCAL_USER => $userId,
242 'application_token' => $handler[
'APPLICATION_TOKEN'],
248 if($handler[
'EVENT_HANDLER'] <>
'')
250 self::$queryData[] = Sqs::queryItem(
251 $application[
'CLIENT_ID'],
252 $handler[
'EVENT_HANDLER'],
254 'event' => $handler[
'EVENT_NAME'],
264 $offlineEvents[] = array(
265 'HANDLER' => $handler,
266 'APPLICATION' => $application,
274 if (count($offlineEvents) > 0)
280 .
"{date} - {host}\n{delimiter}\n"
281 .
"Event count: {eventCount}\n{delimiter}"
282 .
"Offline event list:\n"
285 'eventCount' => count($offlineEvents),
286 'offlineEvents' => $offlineEvents,
290 static::getProviderOffline()->send($offlineEvents);
293 if (count(static::$queryData) > 0 && !static::$forkSet)
299 .
"{date} - {host}\n{delimiter}\n"
300 .
"Registers send event background job.\n"
301 .
"count: {eventCount}",
303 'eventCount' => count(static::$queryData),
307 \Bitrix\Main\Application::getInstance()->addBackgroundJob(array(__CLASS__,
"send"));
308 static::$forkSet =
true;
317 $logger = LoggerManager::getInstance()->getLogger();
322 .
"{date} - {host}\n{delimiter}\n"
323 .
"Starts method Sender::send()\n"
324 .
"count: {eventCount}"
328 'eventCount' => count(static::$queryData),
329 'eventList' => static::$queryData,
333 if (count(self::$queryData) > 0)
335 UsageStatTable::finalize();
336 static::getProvider()->send(self::$queryData);
337 self::$queryData = array();