- Модуль: imconnector
- Путь к файлу: ~/bitrix/modules/imconnector/lib/connectors/network.php
- Класс: BitrixImConnectorConnectorsNetwork
- Вызов: Network::processingInputSessionVote
public function processingInputSessionVote($params, $line): Result
{
$result = new Result();
if (!Loader::includeModule('im'))
{
$result->addError(new Error(
'Failed to load the im module',
'ERROR_IMCONNECTOR_FAILED_LOAD_IM',
__METHOD__
));
}
if (empty($params['USER']) || empty($params['USER']['UUID']))
{
$result->addError(new Error(
'User data not transmitted',
'ERROR_IMCONNECTOR_NOT_TRANSMITTED_USER_DATA',
__METHOD__,
$params
));
}
if ($result->isSuccess())
{
$userId = $this->getUserId($params['USER'], false);
if (empty($userId))
{
$result->addError(new Error(
'Failed to find user',
'ERROR_IMCONNECTOR_FAILED_USER',
__METHOD__,
$params
));
}
}
$messageParams = ['IMOL_VOTE' => 0];
if ($result->isSuccess())
{
$messageParamService = ServiceLocator::getInstance()->get('Im.Services.MessageParam');
if ($messageParamService instanceof BitrixImServicesMessageParam)
{
$messageParams = $messageParamService->getParams((int)$params['MESSAGE_ID']);
}
if (
!isset($messageParams['IMOL_VOTE'])
|| $messageParams['IMOL_VOTE'] != $params['SESSION_ID']
)
{
$result->addError(new Error(
'Voting for the wrong session',
'ERROR_IMCONNECTOR_VOTING_FOR_WRONG_SESSION',
__METHOD__,
$params
));
}
}
$result->setResult(
[
'PARAMS' => $params,
'MESSAGE_PARAMS' => $messageParams,
]
);
return $result;
}