Skip to content

Commit

Permalink
Fix browser push notifications sent not to all users - closes #3880
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-helpdesk committed Apr 19, 2024
1 parent 748c7c5 commit 29d8c41
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,12 @@ public static function processEvents()
$thread_id = self::chooseThread($notify_info['threads'])->id;

foreach ($notify_info['users'] as $user) {
$broadcast_id = $thread_id.'_'.$user->id;
$mediums = [$medium];
if (!empty($broadcasts[$thread_id]['mediums'])) {
$mediums = array_unique(array_merge($mediums, $broadcasts[$thread_id]['mediums']));
if (!empty($broadcasts[$broadcast_id]['mediums'])) {
$mediums = array_unique(array_merge($mediums, $broadcasts[$broadcast_id]['mediums']));
}
$broadcasts[$thread_id] = [
$broadcasts[$broadcast_id] = [
'user' => $user,
'conversation' => $notify_info['conversation'],
'threads' => $notify_info['threads'],
Expand All @@ -422,7 +423,7 @@ public static function processEvents()
}
}
// \Notification::sendNow($notify_info['users'], new BroadcastNotification($notify_info['conversation'], $notify_info['threads'][0]));
foreach ($broadcasts as $thread_id => $to_broadcast) {
foreach ($broadcasts as $broadcast_id => $to_broadcast) {
$broadcast_notification = new BroadcastNotification($to_broadcast['conversation'], self::chooseThread($to_broadcast['threads']), $to_broadcast['mediums']);
$broadcast_notification->delay($delay);
$to_broadcast['user']->notify($broadcast_notification);
Expand Down

0 comments on commit 29d8c41

Please sign in to comment.