Browse Source

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

for-closed-social
Peter Smit 9 years ago
parent
commit
0fa209d07b
1 changed files with 12 additions and 12 deletions
  1. +12
    -12
      routers/user/home.go

+ 12
- 12
routers/user/home.go View File

@ -103,14 +103,14 @@ 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.OwnerId = ctx.User.Id
}
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue
repo := &models.Repository{Id: act.RepoId, IsPrivate: true}
if act.RepoUserName != ctx.User.LowerName {
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue
}
} }
} }
// FIXME: cache results? // FIXME: cache results?
u, err := models.GetUserByName(act.ActUserName) u, err := models.GetUserByName(act.ActUserName)
@ -215,14 +215,14 @@ 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.OwnerId = ctx.User.Id
}
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue
repo := &models.Repository{Id: act.RepoId, IsPrivate: true}
if act.RepoUserName != ctx.User.LowerName {
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue
}
} }
} }
// FIXME: cache results? // FIXME: cache results?
u, err := models.GetUserByName(act.ActUserName) u, err := models.GetUserByName(act.ActUserName)

Loading…
Cancel
Save