mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
Use post isVisibleTo API
This commit is contained in:
@@ -23,13 +23,7 @@ class PushNewPosts
|
|||||||
|
|
||||||
public function pushNewPost(PostWasPosted $event)
|
public function pushNewPost(PostWasPosted $event)
|
||||||
{
|
{
|
||||||
$guest = new Guest;
|
if ($event->post->isVisibleTo(new Guest)) {
|
||||||
$discussion = Discussion::whereVisibleTo($guest)->find($event->post->discussion_id);
|
|
||||||
|
|
||||||
if ($discussion) {
|
|
||||||
$post = $discussion->postsVisibleTo($guest)->find($event->post->id);
|
|
||||||
|
|
||||||
if ($post) {
|
|
||||||
$pusher = new Pusher(
|
$pusher = new Pusher(
|
||||||
$this->settings->get('pusher.app_key'),
|
$this->settings->get('pusher.app_key'),
|
||||||
$this->settings->get('pusher.app_secret'),
|
$this->settings->get('pusher.app_secret'),
|
||||||
@@ -37,11 +31,10 @@ class PushNewPosts
|
|||||||
);
|
);
|
||||||
|
|
||||||
$pusher->trigger('public', 'newPost', [
|
$pusher->trigger('public', 'newPost', [
|
||||||
'postId' => $post->id,
|
'postId' => $event->post->id,
|
||||||
'discussionId' => $discussion->id,
|
'discussionId' => $event->post->discussion->id,
|
||||||
'tagIds' => $discussion->tags()->lists('id')
|
'tagIds' => $event->post->discussion->tags()->lists('id')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user