diff --git a/src/main/scala/gitbucket/core/controller/IndexController.scala b/src/main/scala/gitbucket/core/controller/IndexController.scala index b26282b..9c25fd0 100644 --- a/src/main/scala/gitbucket/core/controller/IndexController.scala +++ b/src/main/scala/gitbucket/core/controller/IndexController.scala @@ -36,23 +36,11 @@ get("/"){ - val loginAccount = context.loginAccount - if(loginAccount.isEmpty) { - gitbucket.core.html.index(getRecentActivities(), - getVisibleRepositories(loginAccount, withoutPhysicalInfo = true), - loginAccount.map{ account => getUserRepositories(account.userName, withoutPhysicalInfo = true) }.getOrElse(Nil) - ) - } else { - val loginUserName = loginAccount.get.userName - val loginUserGroups = getGroupsByUserName(loginUserName) - var visibleOwnerSet : Set[String] = Set(loginUserName) - - visibleOwnerSet ++= loginUserGroups - - gitbucket.core.html.index(getRecentActivitiesByOwners(visibleOwnerSet), - getVisibleRepositories(loginAccount, withoutPhysicalInfo = true), - loginAccount.map{ account => getUserRepositories(account.userName, withoutPhysicalInfo = true) }.getOrElse(Nil) - ) + context.loginAccount.map { account => + val visibleOwnerSet: Set[String] = Set(account.userName) ++ getGroupsByUserName(account.userName) + gitbucket.core.html.index(getRecentActivitiesByOwners(visibleOwnerSet), Nil, getUserRepositories(account.userName, withoutPhysicalInfo = true)) + }.getOrElse { + gitbucket.core.html.index(getRecentActivities(), getVisibleRepositories(None, withoutPhysicalInfo = true), Nil) } } diff --git a/src/main/scala/gitbucket/core/service/RepositoryService.scala b/src/main/scala/gitbucket/core/service/RepositoryService.scala index 322dc01..67ebf72 100644 --- a/src/main/scala/gitbucket/core/service/RepositoryService.scala +++ b/src/main/scala/gitbucket/core/service/RepositoryService.scala @@ -223,7 +223,7 @@ } /** - * Returns the repositories without private repository that user does not have access right. + * Returns the repositories except private repository that user does not have access right. * Include public repository, private own repository and private but collaborator repository. * * @param userName the user name of collaborator @@ -232,8 +232,10 @@ def getAllRepositories(userName: String)(implicit s: Session): List[(String, String)] = { Repositories.filter { t1 => (t1.isPrivate === false.bind) || - (t1.userName === userName.bind) || - (Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && (t2.collaboratorName === userName.bind)} exists) + (t1.userName === userName.bind) || (t1.userName in (GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) || + (Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && + ((t2.collaboratorName === userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) + } exists) }.sortBy(_.lastActivityDate desc).map{ t => (t.userName, t.repositoryName) }.list @@ -242,8 +244,10 @@ def getUserRepositories(userName: String, withoutPhysicalInfo: Boolean = false) (implicit s: Session): List[RepositoryInfo] = { Repositories.filter { t1 => - (t1.userName === userName.bind) || - (Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && (t2.collaboratorName === userName.bind)} exists) + (t1.userName === userName.bind) || (t1.userName in (GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) || + (Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && + ((t2.collaboratorName === userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === userName.bind).map(_.groupName))) + } exists) }.sortBy(_.lastActivityDate desc).list.map{ repository => new RepositoryInfo( if(withoutPhysicalInfo){ @@ -283,7 +287,7 @@ (t.userName in GroupMembers.filter(_.userName === x.userName.bind).map(_.groupName)) || (Collaborators.filter { t2 => t2.byRepository(t.userName, t.repositoryName) && - (t2.collaboratorName === x.userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === x.userName.bind).map(_.groupName)) + ((t2.collaboratorName === x.userName.bind) || (t2.collaboratorName in GroupMembers.filter(_.userName === x.userName.bind).map(_.groupName))) } exists) } // for Guests