Skip to content

Commit

Permalink
[MM-52887] Fix panic if todo is not part of a project (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzei committed Jun 19, 2023
1 parent 4eb8539 commit 9ec4c71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion server/gitlab/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,14 @@ func (g *gitlab) GetUnreads(ctx context.Context, user *UserInfo, token *oauth2.T
}
opt.Page = resp.NextPage
}

notifications := make([]*internGitlab.Todo, 0, len(todos))
for _, todo := range todos {
if g.checkGroup(strings.TrimSuffix(todo.Project.PathWithNamespace, "/"+todo.Project.Path)) != nil {
if todo == nil {
continue
}

if todo.Project != nil && g.checkGroup(strings.TrimSuffix(todo.Project.PathWithNamespace, "/"+todo.Project.Path)) != nil {
continue
}
notifications = append(notifications, todo)
Expand Down
6 changes: 5 additions & 1 deletion server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,11 @@ func (p *Plugin) GetToDo(ctx context.Context, user *gitlab.UserInfo) (bool, stri
notificationContent := ""

for _, n := range unreads {
if p.isNamespaceAllowed(n.Project.NameWithNamespace) != nil {
if n == nil {
continue
}

if n.Project != nil && p.isNamespaceAllowed(n.Project.NameWithNamespace) != nil {
continue
}
notificationCount++
Expand Down

0 comments on commit 9ec4c71

Please sign in to comment.