Fix bug in permission logic

This commit is contained in:
Toby Zerner 2016-05-27 14:46:11 +09:30
parent 4282b9be20
commit cbab23a3f5

View File

@ -32,8 +32,9 @@ class UnapproveNewContent
$post = $event->post;
if (! $post->exists) {
if (($post->discussion->number_index == 0 && $event->actor->can('startWithoutApproval', $post->discussion))
|| $event->actor->can('replyWithoutApproval', $post->discussion)) {
$ability = $post->discussion->number_index == 0 ? 'startWithoutApproval' : 'replyWithoutApproval';
if ($event->actor->can($ability, $post->discussion)) {
if ($post->is_approved === null) {
$post->is_approved = true;
}