Explorar o código

ensure to show GRANT_RESTRICTED pages only when searching by page author

Yuki Takei %!s(int64=7) %!d(string=hai) anos
pai
achega
d3f9e08e34
Modificáronse 1 ficheiros con 6 adicións e 7 borrados
  1. 6 7
      src/server/util/search.js

+ 6 - 7
src/server/util/search.js

@@ -541,23 +541,22 @@ 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() } }
+      ]
+    } },
   ];
   ];
 
 
   if (showPagesRestrictedByOwner) {
   if (showPagesRestrictedByOwner) {
     grantConditions.push(
     grantConditions.push(
-      { term: { grant: GRANT_RESTRICTED } },
       { term: { grant: GRANT_SPECIFIED } },
       { term: { grant: GRANT_SPECIFIED } },
       { term: { grant: GRANT_OWNER } },
       { term: { grant: GRANT_OWNER } },
     );
     );
   }
   }
   else if (user != null) {
   else if (user != null) {
     grantConditions.push(
     grantConditions.push(
-      { bool: {
-        must: [
-          { term: { grant: GRANT_RESTRICTED } },
-          { term: { granted_users: user._id.toString() } }
-        ]
-      } },
       { bool: {
       { bool: {
         must: [
         must: [
           { term: { grant: GRANT_SPECIFIED } },
           { term: { grant: GRANT_SPECIFIED } },