mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
Fix conflicts with other extension visibility scoping (#26)
Wrapping all `wheres` in an `orWhere` ensures that there's no conflict. See https://github.com/flarum/core/issues/2798, https://github.com/flarum/docs/pull/200
This commit is contained in:
committed by
GitHub
parent
dbccc396b0
commit
3b3cbdc82f
@@ -20,6 +20,10 @@ class ScopePrivateDiscussionVisibility
|
||||
*/
|
||||
public function __invoke(User $actor, Builder $query)
|
||||
{
|
||||
// All statements need to be wrapped in an orWhere, since we're adding a
|
||||
// subset of private discussions that should be visible, not restricting the visible
|
||||
// set.
|
||||
$query->orWhere(function ($query) use ($actor) {
|
||||
// Show empty/private discussions if they require approval and they are
|
||||
// authored by the current user, or the current user has permission to
|
||||
// approve posts.
|
||||
@@ -33,5 +37,6 @@ class ScopePrivateDiscussionVisibility
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,10 @@ class ScopePrivatePostVisibility
|
||||
*/
|
||||
public function __invoke(User $actor, Builder $query)
|
||||
{
|
||||
// All statements need to be wrapped in an orWhere, since we're adding a
|
||||
// subset of private posts that should be visible, not restricting the visible
|
||||
// set.
|
||||
$query->orWhere(function ($query) use ($actor) {
|
||||
// Show private posts if they require approval and they are
|
||||
// authored by the current user, or the current user has permission to
|
||||
// approve posts.
|
||||
@@ -32,6 +36,7 @@ class ScopePrivatePostVisibility
|
||||
->orWhereExists($this->discussionWhereCanApprovePosts($actor));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private function discussionWhereCanApprovePosts(User $actor)
|
||||
|
Reference in New Issue
Block a user