diff options
author | 6543 <6543@obermui.de> | 2019-12-03 08:26:02 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-12-03 09:26:02 +0200 |
commit | e43de0db4c4ed883a7b6d3500e796c1ed77d0397 (patch) | |
tree | 3ce07b0d7f66de4a751c5cd4fde13cdd6ace99d5 | |
parent | e459f99ef2016ec698b5392f28919d3d7be1bbdd (diff) | |
download | gitea-e43de0db4c4ed883a7b6d3500e796c1ed77d0397.tar.gz gitea-e43de0db4c4ed883a7b6d3500e796c1ed77d0397.zip |
Fix Dashboard Issues/PR list (#9235)
* fix it
* revert suggestion part
-rw-r--r-- | routers/user/home.go | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/routers/user/home.go b/routers/user/home.go index e0d90dc6e2..8465216bcf 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -285,7 +285,9 @@ func Issues(ctx *context.Context) { } opts.LabelIDs = labelIDs - opts.RepoIDs = repoIDs + if len(repoIDs) > 0 { + opts.RepoIDs = repoIDs + } issues, err := models.Issues(opts) if err != nil { @@ -295,23 +297,29 @@ func Issues(ctx *context.Context) { showReposMap := make(map[int64]*models.Repository, len(counts)) for repoID := range counts { - showReposMap[repoID], err = models.GetRepositoryByID(repoID) - if models.IsErrRepoNotExist(err) { - ctx.NotFound("GetRepositoryByID", err) - return - } else if err != nil { - ctx.ServerError("GetRepositoryByID", fmt.Errorf("[%d]%v", repoID, err)) - return - } + if repoID > 0 { + if _, ok := showReposMap[repoID]; !ok { + repo, err := models.GetRepositoryByID(repoID) + if models.IsErrRepoNotExist(err) { + ctx.NotFound("GetRepositoryByID", err) + return + } else if err != nil { + ctx.ServerError("GetRepositoryByID", fmt.Errorf("[%d]%v", repoID, err)) + return + } + showReposMap[repoID] = repo + } + repo := showReposMap[repoID] - // Check if user has access to given repository. - perm, err := models.GetUserRepoPermission(showReposMap[repoID], ctxUser) - if err != nil { - ctx.ServerError("GetUserRepoPermission", fmt.Errorf("[%d]%v", repoID, err)) - return - } - if !perm.CanRead(models.UnitTypeIssues) { - log.Error("User created Issues in Repository which they no longer have access to: [%d]", repoID) + // Check if user has access to given repository. + perm, err := models.GetUserRepoPermission(repo, ctxUser) + if err != nil { + ctx.ServerError("GetUserRepoPermission", fmt.Errorf("[%d]%v", repoID, err)) + return + } + if !perm.CanRead(models.UnitTypeIssues) { + log.Error("User created Issues in Repository which they no longer have access to: [%d]", repoID) + } } } |