Update/simplify fix that owners also see actions on their repositories

This commit is contained in:
Peter Smit 2015-02-18 08:59:22 +02:00
parent 455fad0fbd
commit 0fa209d07b

View file

@ -103,15 +103,15 @@ func Dashboard(ctx *middleware.Context) {
feeds := make([]*models.Action, 0, len(actions)) feeds := make([]*models.Action, 0, len(actions))
for _, act := range actions { for _, act := range actions {
if act.IsPrivate { if act.IsPrivate {
repo := &models.Repository{Id: act.RepoId, IsPrivate: true}
// This prevents having to retrieve the repository for each action // This prevents having to retrieve the repository for each action
if act.RepoUserName == ctx.User.LowerName { repo := &models.Repository{Id: act.RepoId, IsPrivate: true}
repo.OwnerId = ctx.User.Id if act.RepoUserName != ctx.User.LowerName {
}
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has { if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue continue
} }
} }
}
// FIXME: cache results? // FIXME: cache results?
u, err := models.GetUserByName(act.ActUserName) u, err := models.GetUserByName(act.ActUserName)
if err != nil { if err != nil {
@ -215,15 +215,15 @@ func Profile(ctx *middleware.Context) {
if !ctx.IsSigned { if !ctx.IsSigned {
continue continue
} }
repo := &models.Repository{Id: act.RepoId, IsPrivate: true}
// This prevents having to retrieve the repository for each action // This prevents having to retrieve the repository for each action
if act.RepoUserName == ctx.User.LowerName { repo := &models.Repository{Id: act.RepoId, IsPrivate: true}
repo.OwnerId = ctx.User.Id if act.RepoUserName != ctx.User.LowerName {
}
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has { if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue continue
} }
} }
}
// FIXME: cache results? // FIXME: cache results?
u, err := models.GetUserByName(act.ActUserName) u, err := models.GetUserByName(act.ActUserName)
if err != nil { if err != nil {