瀏覽代碼

ensure to show GRANT_RESTRICTED pages only when searching by page author

Yuki Takei 7 年之前
父節點
當前提交
d3f9e08e34
共有 1 個文件被更改,包括 6 次插入7 次删除
  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 } },