diff --git a/api/src/Json/Push.php b/api/src/Json/Push.php index cd4eb987a6..50b81c2ac8 100644 --- a/api/src/Json/Push.php +++ b/api/src/Json/Push.php @@ -104,6 +104,16 @@ class Push extends Msg return self::$online; } + /** + * Get given user is online / connected to push-server + * + * @return boolean + */ + public function isOnline($account_id) + { + return in_array($account_id, $this->online()); + } + /** * Check and if neccessary set push backend * diff --git a/notifications/inc/class.notifications.inc.php b/notifications/inc/class.notifications.inc.php index 84ec2ac23c..ac9ecec83c 100644 --- a/notifications/inc/class.notifications.inc.php +++ b/notifications/inc/class.notifications.inc.php @@ -489,6 +489,7 @@ class notifications { Api\Translation::add_app('notifications'); $available_chains = $this->get_available_chains('routing'); + $push = new Api\Json\Push(); foreach ($this->receivers as $receiver) { $user_notified = false; @@ -574,7 +575,7 @@ class notifications { // This is to make popup_or_email option sensfull since // we save popup notifications in database anyway, email // notifications should be based on user availability. - if ($backend == 'popup' && $action== 'fail' && !Api\Session::notifications_active($receiver->account_id)) + if ($backend === 'popup' && $action === 'fail' && !$push->isOnline($receiver->account_id)) { throw new Exception(); }