diff --git a/framework/core/src/Api/Actions/Forum/ShowAction.php b/framework/core/src/Api/Actions/Forum/ShowAction.php index b8aebaf34..a6b03a358 100644 --- a/framework/core/src/Api/Actions/Forum/ShowAction.php +++ b/framework/core/src/Api/Actions/Forum/ShowAction.php @@ -56,7 +56,7 @@ class ShowAction extends SerializeResourceAction { $forum = app('flarum.forum'); - $forum->groups = Group::all(); + $forum->groups = Group::whereVisibleTo($request->actor)->get(); return $forum; } diff --git a/framework/core/src/Api/Serializers/ForumSerializer.php b/framework/core/src/Api/Serializers/ForumSerializer.php index 381b2bd83..67c8708d6 100644 --- a/framework/core/src/Api/Serializers/ForumSerializer.php +++ b/framework/core/src/Api/Serializers/ForumSerializer.php @@ -29,6 +29,7 @@ class ForumSerializer extends Serializer 'welcomeTitle' => Core::config('welcome_title'), 'welcomeMessage' => Core::config('welcome_message'), 'themePrimaryColor' => Core::config('theme_primary_color'), + 'canView' => $forum->can($this->actor, 'view'), 'canStartDiscussion' => $forum->can($this->actor, 'startDiscussion') ]; diff --git a/framework/core/src/Core/Support/VisibleScope.php b/framework/core/src/Core/Support/VisibleScope.php index 228fd955a..00f6135d5 100644 --- a/framework/core/src/Core/Support/VisibleScope.php +++ b/framework/core/src/Core/Support/VisibleScope.php @@ -14,6 +14,10 @@ trait VisibleScope */ public function scopeWhereVisibleTo(Builder $query, User $actor) { - event(new ScopeModelVisibility($this, $query, $actor)); + if (! app('flarum.forum')->can($actor, 'view')) { + $query->whereRaw('FALSE'); + } else { + event(new ScopeModelVisibility($this, $query, $actor)); + } } }