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.
This commit is contained in:
Daniël Klabbers 2020-09-02 19:55:45 +02:00 committed by GitHub
parent 2e1c8d79d4
commit 619796b102

View File

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