* Notifications: taking push server into account for checking user is online for popup or email notifications

This commit is contained in:
Ralf Becker 2020-07-31 17:50:01 +02:00
parent 0e3143d45d
commit 3972abdf52
2 changed files with 12 additions and 1 deletions

View File

@ -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
*

View File

@ -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();
}