From 619796b102fc15f50fd0dd9875ea50a5e4fd7f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Wed, 2 Sep 2020 19:55:45 +0200 Subject: [PATCH] Reduces friction with flarum/tags (#25) Instead of blatantly triggering a 500 let's try to see whether the tags relation is even returning anything before we try to pluck tag ids from it when we publish that data to the pusher server. --- extensions/pusher/src/Listener/PushNewPost.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/pusher/src/Listener/PushNewPost.php b/extensions/pusher/src/Listener/PushNewPost.php index 4c20218d1..a55f1014e 100644 --- a/extensions/pusher/src/Listener/PushNewPost.php +++ b/extensions/pusher/src/Listener/PushNewPost.php @@ -28,10 +28,12 @@ class PushNewPost public function handle(Posted $event) { if ($event->post->isVisibleTo(new Guest)) { + $tags = $event->post->discussion->tags; + $this->pusher->trigger('public', 'newPost', [ 'postId' => $event->post->id, 'discussionId' => $event->post->discussion->id, - 'tagIds' => $event->post->discussion->tags()->pluck('id') + 'tagIds' => $tags ? $tags->pluck('id') : null ]); } }