|
@@ -541,14 +541,20 @@ SearchClient.prototype.filterPagesByViewer = async function(query, user, userGro
|
|
|
|
|
|
|
|
const grantConditions = [
|
|
const grantConditions = [
|
|
|
{ term: { grant: GRANT_PUBLIC } },
|
|
{ term: { grant: GRANT_PUBLIC } },
|
|
|
- { bool: {
|
|
|
|
|
- must: [
|
|
|
|
|
- { term: { grant: GRANT_RESTRICTED } },
|
|
|
|
|
- { term: { granted_users: user._id.toString() } }
|
|
|
|
|
- ]
|
|
|
|
|
- } },
|
|
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+ // ensure to hit to GRANT_RESTRICTED pages that the user specified at own
|
|
|
|
|
+ if (user != null) {
|
|
|
|
|
+ grantConditions.push(
|
|
|
|
|
+ { bool: {
|
|
|
|
|
+ must: [
|
|
|
|
|
+ { term: { grant: GRANT_RESTRICTED } },
|
|
|
|
|
+ { term: { granted_users: user._id.toString() } }
|
|
|
|
|
+ ]
|
|
|
|
|
+ } }
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (showPagesRestrictedByOwner) {
|
|
if (showPagesRestrictedByOwner) {
|
|
|
grantConditions.push(
|
|
grantConditions.push(
|
|
|
{ term: { grant: GRANT_SPECIFIED } },
|
|
{ term: { grant: GRANT_SPECIFIED } },
|