- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/V2/Message/Send/PushService.php
- Класс: BitrixImV2MessageSendPushService
- Вызов: PushService::sendPushNotification
public function sendPushNotification(NotifyChat $chat, Message $message, int $counter = 0, bool $sendNotifyFlash = true): void
{
if (!$this->isPullEnable())
{
return;
}
$toUserId = $chat->getAuthorId();
$pullNotificationParams = $this->getFormatNotify($message, $counter);
// We shouldn't send push, if it is disabled in notification settings.
$needPush = CIMSettings::GetNotifyAccess(
$toUserId,
$message->getNotifyModule(),
$message->getNotifyEvent(),
CIMSettings::CLIENT_PUSH
);
if ($needPush)
{
// we prepare push params ONLY if there are no ADVANCED_PARAMS from outside.
// If ADVANCED_PARAMS exists we must not change them.
$pushParams = $message->getPushParams();
if (isset($pushParams['ADVANCED_PARAMS']))
{
$advancedParams = $pushParams['ADVANCED_PARAMS'];
unset($pushParams['ADVANCED_PARAMS']);
}
else
{
$advancedParams = $this->prepareAdvancedParamsForNotificationPush(
$pullNotificationParams,
$message->getPushMessage()
);
}
BitrixPullPush::add(
$toUserId,
[
'module_id' => $message->getNotifyModule(),
'push' => [
'type' => $message->getNotifyEvent(),
'message' => $message->getPushMessage(),
'params' => $message->getPushParams() ?? ['TAG' => 'IM_NOTIFY'],
'advanced_params' => $advancedParams,
'important' => ($this->sendingConfig->sendPushImmediately() ? 'Y': 'N'),
'tag' => $message->getNotifyTag(),
'sub_tag' => $message->getNotifySubTag(),
'app_id' => $message->getPushAppId() ?? '',
]
]
);
}
//($message->isNotifyFlash() ?? false),
if ($sendNotifyFlash)
{
BitrixPullEvent::add(
$toUserId,
[
'module_id' => 'im',
'command' => 'notifyAdd',
'params' => $pullNotificationParams,
'extra' => BitrixImCommon::getPullExtra()
]
);
}
}