fix: don't try to load subscriptions for nonexistent projects

This commit is contained in:
kolaente 2023-07-03 18:18:13 +02:00
parent 32689531ec
commit b5194624e0
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 5 additions and 1 deletions

View File

@ -262,6 +262,9 @@ func getSubscriptionsForProjects(s *xorm.Session, projectIDs []int64, u *user.Us
var ps = make(map[int64]*Project)
for _, eID := range projectIDs {
if eID < 1 {
continue
}
ps[eID], err = GetProjectSimpleByID(s, eID)
if err != nil {
return nil, err
@ -309,7 +312,8 @@ func getSubscriptionsForProjects(s *xorm.Session, projectIDs []int64, u *user.Us
// If the current project does not have a subscription, climb up the tree until a project has one,
// then use that subscription for all child projects
_, has := projectsToSubscriptions[eID]
if !has {
_, hasProject := ps[eID]
if !has && hasProject {
var parent = ps[eID].ParentProject
for parent != nil {
sub, has := projectsToSubscriptions[parent.ID]