1
0
mirror of https://github.com/flarum/core.git synced 2025-08-02 14:37:49 +02:00

Notification one-per-user limit should work between instances

This commit is contained in:
Toby Zerner
2015-07-23 14:33:58 +09:30
parent 6d57f902b3
commit 5b54a122c9

View File

@@ -17,14 +17,14 @@ class NotificationSyncer
* *
* @var bool * @var bool
*/ */
protected $onePerUser = false; protected static $onePerUser = false;
/** /**
* An internal list of user IDs that notifications have been sent to. * An internal list of user IDs that notifications have been sent to.
* *
* @var int[] * @var int[]
*/ */
protected $sentTo = []; protected static $sentTo = [];
/** /**
* @var NotificationRepository * @var NotificationRepository
@@ -80,9 +80,9 @@ class NotificationSyncer
if ($existing) { if ($existing) {
$toUndelete[] = $existing->id; $toUndelete[] = $existing->id;
$toDelete->forget($toDelete->search($existing)); $toDelete->forget($toDelete->search($existing));
} elseif (! $this->onePerUser || ! in_array($user->id, $this->sentTo)) { } elseif (! static::$onePerUser || ! in_array($user->id, static::$sentTo)) {
$newRecipients[] = $user; $newRecipients[] = $user;
$this->sentTo[] = $user->id; static::$sentTo[] = $user->id;
} }
} }
@@ -136,12 +136,12 @@ class NotificationSyncer
*/ */
public function onePerUser(callable $callback) public function onePerUser(callable $callback)
{ {
$this->sentTo = []; static::$sentTo = [];
$this->onePerUser = true; static::$onePerUser = true;
$callback(); $callback();
$this->onePerUser = false; static::$onePerUser = false;
} }
/** /**
@@ -169,7 +169,7 @@ class NotificationSyncer
); );
if ($blueprint instanceof MailableBlueprint) { if ($blueprint instanceof MailableBlueprint) {
$this->mailNotifications($blueprint); $this->mailNotifications($blueprint, $recipients);
} }
} }