From c5e902926bcdd87d6dd882d1659b7e133767b600 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 23 Jul 2018 16:24:47 +0200 Subject: [PATCH] Fix notifications with same id but no links are not getting grouped together --- api/src/Storage/Tracking.php | 1 + calendar/inc/class.calendar_boupdate.inc.php | 3 ++- notifications/inc/class.notifications_ajax.inc.php | 2 +- notifications/js/notificationajaxpopup.js | 13 +++++++------ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/api/src/Storage/Tracking.php b/api/src/Storage/Tracking.php index 3a4a929f40..f42a685023 100644 --- a/api/src/Storage/Tracking.php +++ b/api/src/Storage/Tracking.php @@ -804,6 +804,7 @@ abstract class Tracking $notification->set_sender($sender); $notification->set_subject($subject); $notification->set_links(array($link)); + $notification->set_popupdata($link['app'], $link); if ($attachments && is_array($attachments)) { $notification->set_attachments($attachments); diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index 3b3a3b6573..d26cffadb2 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -1098,7 +1098,8 @@ class calendar_boupdate extends calendar_bo $notification->set_popupdata('calendar', array( 'event_id' => $event['id'], 'user_id' => $userid, - 'type' => $m_type + 'type' => $m_type, + 'id' => $event['id'] )); } if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1, 'type' => $m_type)); diff --git a/notifications/inc/class.notifications_ajax.inc.php b/notifications/inc/class.notifications_ajax.inc.php index 8997ca760a..c7b2bf7ec9 100644 --- a/notifications/inc/class.notifications_ajax.inc.php +++ b/notifications/inc/class.notifications_ajax.inc.php @@ -201,7 +201,7 @@ class notifications_ajax { 'created' => Api\DateTime::to($notification['notify_created']), 'current' => new DateTime(), 'actions' => is_array($actions)?$actions:NULL, - 'extra_data' => $data['data'] + 'extra_data' => ($data['data'] ? $data['data'] : array()) ); } diff --git a/notifications/js/notificationajaxpopup.js b/notifications/js/notificationajaxpopup.js index 73788d8fc6..bba7bc463e 100644 --- a/notifications/js/notificationajaxpopup.js +++ b/notifications/js/notificationajaxpopup.js @@ -602,10 +602,10 @@ notifymessages = {}; for (var i=0; i < _rawData.length; i++) { - var data = this.getData(_rawData[i]['message']); + var data = this.getData(_rawData[i]['message'], _rawData[i]['extra_data']); var parent; if ((parent = this.findParent(data['id'], data['app'])) - && !(_rawData[i]['extra_data'] && typeof _rawData[i]['extra_data']['egw_pr_notify'] == 'undefined')) + && typeof _rawData[i]['extra_data']['egw_pr_notify'] == 'undefined') { if (parent == _rawData[i]['id']) continue; if (!notifymessages[parent]['children']) notifymessages[parent] = jQuery.extend(notifymessages[parent], {children:{}}); @@ -617,7 +617,7 @@ current: _rawData[i]['current'], extra_data: _rawData[i]['extra_data'] }; - if (_rawData[i]['actions'] && _rawData[i]['actions'].length > 0) notifymessages[parent]['children'][_rawData[i]]['data']['actions'] = _rawData[i]['actions']; + if (_rawData[i]['actions'] && _rawData[i]['actions'].length > 0) notifymessages[parent]['children'][_rawData[i]['id']]['data']['actions'] = _rawData[i]['actions']; continue; } @@ -698,15 +698,16 @@ * @param {type} _message * @returns {notificationajaxpopup_L15.notifications.prototype.getData.data} */ - notifications.prototype.getData = function (_message) { - var dom = jQuery(document.createElement('div')).html(_message);; + notifications.prototype.getData = function (_message, _extra_data) { + var dom = jQuery(document.createElement('div')).html(_message); + var extra_data = _extra_data || {}; var link = dom.find('div[data-id],div[data-url]'); var data = { message: dom.text(), title: link.text(), icon: link.find('img').attr('src') }; - jQuery.extend(data,link.data()); + jQuery.extend(data,link.data(), extra_data); return typeof data == 'object'? data: {}; };