Show newsfeed of private repo to members of owner group

This commit is contained in:
utensil
2014-06-22 09:59:59 +00:00
parent 1223bf2fd8
commit 3683a5fb7d
2 changed files with 10 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ class IndexController extends IndexControllerBase
with RepositoryService with ActivityService with AccountService with UsersAuthenticator with RepositoryService with ActivityService with AccountService with UsersAuthenticator
trait IndexControllerBase extends ControllerBase { trait IndexControllerBase extends ControllerBase {
self: RepositoryService with ActivityService with AccountService with UsersAuthenticator => self: RepositoryService with ActivityService with AccountService with UsersAuthenticator =>
case class SignInForm(userName: String, password: String) case class SignInForm(userName: String, password: String)
@@ -26,7 +27,13 @@ trait IndexControllerBase extends ControllerBase {
loginAccount.map{ account => getUserRepositories(account.userName, context.baseUrl, withoutPhysicalInfo = true) }.getOrElse(Nil) loginAccount.map{ account => getUserRepositories(account.userName, context.baseUrl, withoutPhysicalInfo = true) }.getOrElse(Nil)
) )
} else { } else {
html.index(getRecentActivitiesByUser(loginAccount.get.userName), val loginUserName = loginAccount.get.userName
val loginUserGroups = getGroupsByUserName(loginUserName)
var visibleOwnerSet : Set[String] = Set(loginUserName)
visibleOwnerSet ++= loginUserGroups
html.index(getRecentActivitiesByOwners(visibleOwnerSet),
getVisibleRepositories(loginAccount, context.baseUrl, withoutPhysicalInfo = true), getVisibleRepositories(loginAccount, context.baseUrl, withoutPhysicalInfo = true),
loginAccount.map{ account => getUserRepositories(account.userName, context.baseUrl, withoutPhysicalInfo = true) }.getOrElse(Nil) loginAccount.map{ account => getUserRepositories(account.userName, context.baseUrl, withoutPhysicalInfo = true) }.getOrElse(Nil)
) )

View File

@@ -31,10 +31,10 @@ trait ActivityService {
.take(30) .take(30)
.list .list
def getRecentActivitiesByUser(loginUserName : String): List[Activity] = def getRecentActivitiesByOwners(owners : Set[String]): List[Activity] =
Activities Activities
.innerJoin(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName)) .innerJoin(Repositories).on((t1, t2) => t1.byRepository(t2.userName, t2.repositoryName))
.filter { case (t1, t2) => (t2.isPrivate is false.bind) || (t2.userName is loginUserName.bind) } .filter { case (t1, t2) => (t2.isPrivate is false.bind) || (t2.userName inSetBind owners) }
.sortBy { case (t1, t2) => t1.activityId desc } .sortBy { case (t1, t2) => t1.activityId desc }
.map { case (t1, t2) => t1 } .map { case (t1, t2) => t1 }
.take(30) .take(30)