Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Visibility Scoping Extender and Tests #2460

Merged
merged 18 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use whereVisibleTo for visibility scoping that includes an ability
  • Loading branch information
askvortsov1 committed Dec 2, 2020
commit 7734f4d18367457fad34d3b4505aaa1fe5e778b9
6 changes: 3 additions & 3 deletions src/Discussion/Access/ScopeDiscussionVisibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __invoke(User $actor, $query)
$query->where(function ($query) use ($actor) {
$query->where('discussions.is_private', false)
->orWhere(function ($query) use ($actor) {
$query->whereVisibleWithAbility($actor, 'viewPrivate');
$query->whereVisibleTo($actor, 'viewPrivate');
});
});

Expand All @@ -41,7 +41,7 @@ public function __invoke(User $actor, $query)
$query->whereNull('discussions.hidden_at')
->orWhere('discussions.user_id', $actor->id)
->orWhere(function ($query) use ($actor) {
$query->whereVisibleWithAbility($actor, 'hide');
$query->whereVisibleTo($actor, 'hide');
});
});
}
Expand All @@ -53,7 +53,7 @@ public function __invoke(User $actor, $query)
$query->where('discussions.comment_count', '>', 0)
->orWhere('discussions.user_id', $actor->id)
->orWhere(function ($query) use ($actor) {
$query->whereVisibleWithAbility($actor, 'editPosts');
$query->whereVisibleTo($actor, 'editPosts');
});
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/Post/Access/ScopePostVisibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __invoke(User $actor, $query)
$query->where(function ($query) use ($actor) {
$query->where('posts.is_private', false)
->orWhere(function ($query) use ($actor) {
$query->whereVisibleWithAbility($actor, 'viewPrivate');
$query->whereVisibleTo($actor, 'viewPrivate');
});
});

Expand All @@ -52,7 +52,7 @@ public function __invoke(User $actor, $query)
$query
->whereRaw('1=0')
->orWhere(function ($query) use ($actor) {
Discussion::query()->setQuery($query)->whereVisibleWithAbility($actor, 'hidePosts');
Discussion::query()->setQuery($query)->whereVisibleTo($actor, 'hidePosts');
});
});
});
Expand Down