aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorPeter Smit <peter@smitmail.eu>2015-02-16 13:16:24 +0200
committerPeter Smit <peter@smitmail.eu>2015-02-16 13:16:24 +0200
commit455fad0fbd85137af5d3efec93d2b974e9383b98 (patch)
treeb52292aac1c78d00cd3fc0d8f3b35146fd036b0f /routers
parentcd6a2b78a752605d808c6392ce78b92d4759fede (diff)
downloadgitea-455fad0fbd85137af5d3efec93d2b974e9383b98.tar.gz
gitea-455fad0fbd85137af5d3efec93d2b974e9383b98.zip
Fix that owners also see actions on their repositories
This is a balance between speed and nice code, where speed has won. To prevent a repository query for each action the ownername is match with the current user. It would be "cleaner" or "better" if we fetch the repository each time. Another option is to add the RepoOwnerID to action
Diffstat (limited to 'routers')
-rw-r--r--routers/user/home.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/routers/user/home.go b/routers/user/home.go
index 35407534f9..574c6387dc 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -103,7 +103,12 @@ func Dashboard(ctx *middleware.Context) {
feeds := make([]*models.Action, 0, len(actions))
for _, act := range actions {
if act.IsPrivate {
- if has, _ := models.HasAccess(ctx.User, &models.Repository{Id: act.RepoId, IsPrivate: true}, models.ACCESS_MODE_READ); !has {
+ repo := &models.Repository{Id: act.RepoId, IsPrivate: true}
+ // 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
}
}
@@ -210,11 +215,12 @@ func Profile(ctx *middleware.Context) {
if !ctx.IsSigned {
continue
}
- if has, _ := models.HasAccess(ctx.User,
- &models.Repository{
- Id: act.RepoId,
- IsPrivate: true,
- }, models.ACCESS_MODE_READ); !has {
+ repo := &models.Repository{Id: act.RepoId, IsPrivate: true}
+ // 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
}
}