From c7aeef19ead13a9804adf0c00895ee66d705c91e Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 11 Jan 2018 14:06:43 +1030 Subject: [PATCH] Remove use of event priorities Event priorities are no longer in Laravel - see https://github.com/laravel/framework/commit/dbbfc62beff1625b0d45bbf39650d047555cf4fa Now we can't force this event listener to be run before the discussion metadata is updated; instead we just subtract one off of the new last post number. --- .../src/Listener/SendNotificationWhenReplyIsPosted.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/extensions/subscriptions/src/Listener/SendNotificationWhenReplyIsPosted.php b/extensions/subscriptions/src/Listener/SendNotificationWhenReplyIsPosted.php index ecf42fdc8..582307282 100755 --- a/extensions/subscriptions/src/Listener/SendNotificationWhenReplyIsPosted.php +++ b/extensions/subscriptions/src/Listener/SendNotificationWhenReplyIsPosted.php @@ -44,10 +44,7 @@ class SendNotificationWhenReplyIsPosted { $events->listen(ConfigureNotificationTypes::class, [$this, 'addNotificationType']); - // Register with '1' as priority so this runs before discussion metadata - // is updated, as we need to compare the user's last read number to that - // of the previous post. - $events->listen(Posted::class, [$this, 'whenPosted'], 1); + $events->listen(Posted::class, [$this, 'whenPosted']); $events->listen(Hidden::class, [$this, 'whenHidden']); $events->listen(Restored::class, [$this, 'whenRestored']); $events->listen(Deleted::class, [$this, 'whenDeleted']); @@ -72,7 +69,7 @@ class SendNotificationWhenReplyIsPosted $notify = $discussion->readers() ->where('users.id', '!=', $post->user_id) ->where('users_discussions.subscription', 'follow') - ->where('users_discussions.read_number', $discussion->last_post_number) + ->where('users_discussions.read_number', $discussion->last_post_number - 1) ->get(); $this->notifications->sync(