Skip to content

Commit

Permalink
Ticket #4558 - Build-in API support: URLs in push notifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLV committed Aug 29, 2024
1 parent 93db31f commit 60e6422
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions inc/classes/BxDolPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,29 +145,44 @@ public function send($iProfileId, $aMessage, $bAddToQueue = false)
return false;

if($bAddToQueue && BxDolQueuePush::getInstance()->add($iProfileId, $aMessage))
return true;

if(($sRootUrl = getParam('sys_api_url_root_push')) !== '') {
return true;

$sUrlWeb = $sUrlApp = !empty($aMessage['url']) ? $aMessage['url'] : '';

if(($sRootUrl = getParam('sys_api_url_root_email')) !== '') {
if(substr(BX_DOL_URL_ROOT, -1) == '/' && substr($sRootUrl, -1) != '/')
$sRootUrl .= '/';

if(!empty($aMessage['url']))
$aMessage['url'] = str_replace(BX_DOL_URL_ROOT, $sRootUrl, $aMessage['url']);
if($sUrlWeb)
$sUrlWeb = str_replace(BX_DOL_URL_ROOT, $sRootUrl, $sUrlWeb);

if(empty($aMessage['contents']) && is_array($aMessage['contents']))
foreach($aMessage['contents'] as $sKey => $sValue)
$aMessage['contents'][$sKey] = str_replace(BX_DOL_URL_ROOT, $sRootUrl, $sValue);
}

if(($sRootUrl = getParam('sys_api_url_root_push')) !== '') {
if(substr(BX_DOL_URL_ROOT, -1) == '/' && substr($sRootUrl, -1) != '/')
$sRootUrl .= '/';

if($sUrlApp)
$sUrlApp = str_replace(BX_DOL_URL_ROOT, $sRootUrl, $sUrlApp);
}
else
$sUrlApp = $sUrlWeb;

$aFields = [
'app_id' => $this->_sAppId,
'filters' => [
['field' => 'tag', 'key' => 'user_hash', 'relation' => '=', 'value' => encryptUserId($iProfileId)]
],
'contents' => !empty($aMessage['contents']) && is_array($aMessage['contents']) ? $aMessage['contents'] : [],
'headings' => !empty($aMessage['headings']) && is_array($aMessage['headings']) ? $aMessage['headings'] : [],
'url' => !empty($aMessage['url']) ? $aMessage['url'] : '',
'data' => array('url' => !empty($aMessage['url']) ? $aMessage['url'] : ''),
'web_url' => $sUrlWeb,
'app_url' => $sUrlApp,
'data' => [
'url' => $sUrlWeb
],
'chrome_web_icon' => !empty($aMessage['icon']) ? $aMessage['icon'] : '',
];

Expand Down

0 comments on commit 60e6422

Please sign in to comment.