- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/V2/Message/Send/PushService.php
- Класс: BitrixImV2MessageSendPushService
- Вызов: PushService::getFormatNotify
private function getFormatNotify(Message $message, int $counter = 0): array
{
$messageText = Text::parse(
Text::convertHtmlToBbCode($message->getMessage()),
[
'LINK' => 'Y', // (isset($arFields['HIDE_LINK']) && $arFields['HIDE_LINK'] === 'Y') ? 'N' : 'Y',
'LINK_TARGET_SELF' => 'Y',
'SAFE' => 'N',
'FONT' => 'Y',
'SMILES' => 'N',
]
);
$notify = [
'id' => $message->getMessageId(),
'type' => $message->getNotifyType(),
'date' => DateTime::createFromTimestamp(time()), // DATE_CREATE
'silent' => 'N', //($arFields['NOTIFY_SILENT'] ?? null) ? 'Y' : 'N',
'onlyFlash' => ($message->isNotifyFlash() ?? false),
'link' => ($message->getNotifyLink() ?? ''),
'text' => $messageText,
'tag' => ($message->getNotifyTag() ? md5($message->getNotifyTag()) : ''),
'originalTag' => $message->getNotifyTag(),
'original_tag' => $message->getNotifyTag(),
'read' => $message->isNotifyRead() !== null ? ($message->isNotifyRead() ? 'Y' : 'N') : null,
'settingName' => $message->getNotifyModule(). '|'. $message->getNotifyEvent(),
'params' => $message->getParams()->toPullFormat(),
'counter' => $counter,
'users' => [],
'userId' => null,
'userName' => null,
'userColor' => null,
'userAvatar' => null,
'userLink' => null,
];
if ($message->getAuthorId())
{
$notify['users'][] = $message->getAuthor()->getArray([
'JSON' => 'Y',
'SKIP_ONLINE' => 'Y'
]);
$notify['userId'] = $message->getAuthorId();
$notify['userName'] = $message->getAuthor()->getName();
$notify['userColor'] = $message->getAuthor()->getColor();
$notify['userAvatar'] = $message->getAuthor()->getAvatar();
$notify['userLink'] = $message->getAuthor()->getProfile();
}
if ($message->getNotifyType() == IM_NOTIFY_CONFIRM)
{
$notify['buttons'] = $message->getNotifyButtons();
}
else
{
$notify['title'] = htmlspecialcharsbx($message->getNotifyTitle());
}
return $notify;
}