From 18b90d16e337d5a355ba556fb6aa0815063db7d4 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Wed, 14 Nov 2018 09:21:30 +1030 Subject: [PATCH] Allow users to hide their own posts just as they can edit them This fixes a regression introduced by #1466. --- src/Post/PostPolicy.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Post/PostPolicy.php b/src/Post/PostPolicy.php index 5dee602a6..c0b1a28c3 100644 --- a/src/Post/PostPolicy.php +++ b/src/Post/PostPolicy.php @@ -115,9 +115,9 @@ class PostPolicy extends AbstractPolicy */ public function edit(User $actor, Post $post) { - // A post is allowed to be edited if the user has permission to moderate - // the discussion which it's in, or if they are the author and the post - // hasn't been deleted by someone else. + // A post is allowed to be edited if the user is the author, the post + // hasn't been deleted by someone else, and the user is allowed to + // create new replies in the discussion. if ($post->user_id == $actor->id && (! $post->hidden_at || $post->hidden_user_id == $actor->id) && $actor->can('reply', $post->discussion)) { $allowEditing = $this->settings->get('allow_post_editing'); @@ -128,4 +128,14 @@ class PostPolicy extends AbstractPolicy } } } + + /** + * @param User $actor + * @param Post $post + * @return bool|null + */ + public function hide(User $actor, Post $post) + { + return $this->edit($actor, $post); + } }