Yuki Takei 7 лет назад
Родитель
Сommit
6ae604ef19
1 измененных файлов с 4 добавлено и 12 удалено
  1. 4 12
      src/server/util/search.js

+ 4 - 12
src/server/util/search.js

@@ -531,16 +531,8 @@ SearchClient.prototype.filterPagesByViewer = async function(query, user, userGro
   const Config = this.crowi.model('Config');
   const config = this.crowi.getConfig();
 
-  // determine User condition
   const hidePagesRestrictedByOwner = Config.hidePagesRestrictedByOwnerInList(config);
-  user = hidePagesRestrictedByOwner ? user : null;
-
-  // determine UserGroup condition
   const hidePagesRestrictedByGroup = Config.hidePagesRestrictedByGroupInList(config);
-  if (hidePagesRestrictedByGroup && user != null) {
-    const UserGroupRelation = this.crowi.model('UserGroupRelation');
-    userGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
-  }
 
   query = this.initializeBoolQuery(query);
 
@@ -551,14 +543,14 @@ SearchClient.prototype.filterPagesByViewer = async function(query, user, userGro
     { term: { grant: GRANT_PUBLIC } },
   ];
 
-  if (user == null) {
+  if (!hidePagesRestrictedByOwner) {
     grantConditions.push(
       { term: { grant: GRANT_RESTRICTED } },
       { term: { grant: GRANT_SPECIFIED } },
       { term: { grant: GRANT_OWNER } },
     );
   }
-  else {
+  else if (user != null) {
     grantConditions.push(
       { bool: {
         must: [
@@ -581,12 +573,12 @@ SearchClient.prototype.filterPagesByViewer = async function(query, user, userGro
     );
   }
 
-  if (userGroups == null) {
+  if (!hidePagesRestrictedByGroup) {
     grantConditions.push(
       { term: { grant: GRANT_USER_GROUP } },
     );
   }
-  else if (userGroups.length > 0) {
+  else if (userGroups != null && userGroups.length > 0) {
     const userGroupIds = userGroups.map(group => group._id.toString() );
     grantConditions.push(
       { bool: {