mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 06:53:47 +08:00
Grant users permission to view empty discussions if they can edit posts
This fixes an issue where unapproved discussions (via flarum-ext-approval) that were rejected became invisible to the user. This solution is imperfect and some more substantial thought into how flarum-ext-approval works is required in the future.
This commit is contained in:
parent
b5eab781f1
commit
4af6acdbda
|
@ -103,16 +103,18 @@ class DiscussionPolicy extends AbstractPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide discussions with no comments, unless they are authored by the
|
// Hide discussions with no comments, unless they are authored by the
|
||||||
// current user.
|
// current user, or the user is allowed to edit the discussion's posts.
|
||||||
$query->where(function ($query) use ($actor) {
|
if (! $actor->hasPermission('discussion.editPosts')) {
|
||||||
$query->where('comments_count', '>', 0)
|
$query->where(function ($query) use ($actor) {
|
||||||
->orWhere('start_user_id', $actor->id)
|
$query->where('comments_count', '>', 0)
|
||||||
->orWhere(function ($query) use ($actor) {
|
->orWhere('start_user_id', $actor->id)
|
||||||
$this->events->fire(
|
->orWhere(function ($query) use ($actor) {
|
||||||
new ScopeModelVisibility($query, $actor, 'viewEmpty')
|
$this->events->fire(
|
||||||
);
|
new ScopeModelVisibility($query, $actor, 'editPosts')
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user