Allow users to hide their own posts just as they can edit them

This fixes a regression introduced by #1466.
This commit is contained in:
Toby Zerner 2018-11-14 09:21:30 +10:30
parent 64a7e8ac3a
commit 18b90d16e3

View File

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