mirror of
https://github.com/flarum/core.git
synced 2025-08-03 15:07:53 +02:00
fix(approval): unapproved posts visible to all when no visibility scopers are added
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace Flarum\Approval\Access;
|
namespace Flarum\Approval\Access;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
use Flarum\Discussion\Discussion;
|
use Flarum\Discussion\Discussion;
|
||||||
use Flarum\User\User;
|
use Flarum\User\User;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
@@ -39,15 +40,24 @@ class ScopePrivatePostVisibility
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function discussionWhereCanApprovePosts(User $actor)
|
/**
|
||||||
|
* Looks if the actor has permission to approve posts,
|
||||||
|
* within the discussion which the post is a part of.
|
||||||
|
*
|
||||||
|
* For example, the tags extension,
|
||||||
|
* turns the `approvePosts` ability into per tag basis.
|
||||||
|
*/
|
||||||
|
private function discussionWhereCanApprovePosts(User $actor): Closure
|
||||||
{
|
{
|
||||||
return function ($query) use ($actor) {
|
return function ($query) use ($actor) {
|
||||||
$query->selectRaw('1')
|
$query->selectRaw('1')
|
||||||
->from('discussions')
|
->from('discussions')
|
||||||
->whereColumn('discussions.id', 'posts.discussion_id')
|
->whereColumn('discussions.id', 'posts.discussion_id')
|
||||||
->where(function ($query) use ($actor) {
|
->where(function ($query) use ($actor) {
|
||||||
|
$query->whereRaw('1 != 1')->orWhere(function ($query) use ($actor) {
|
||||||
Discussion::query()->setQuery($query)->whereVisibleTo($actor, 'approvePosts');
|
Discussion::query()->setQuery($query)->whereVisibleTo($actor, 'approvePosts');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user