From 95ef4e1045d74a2244cf6c88f220027ebaf6da54 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 4 Sep 2024 21:55:14 +0200 Subject: [PATCH] fix(subscriptions): do not panic when a task does not have a subscription (cherry picked from commit 75f3e930cd8072fc6709d1e653b177263d02c8ce) --- pkg/models/subscription.go | 2 +- pkg/models/tasks.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/models/subscription.go b/pkg/models/subscription.go index 91431f4d8..c0bf9e1eb 100644 --- a/pkg/models/subscription.go +++ b/pkg/models/subscription.go @@ -171,7 +171,7 @@ func (sb *Subscription) Delete(s *xorm.Session, auth web.Auth) (err error) { func GetSubscriptionForUser(s *xorm.Session, entityType SubscriptionEntityType, entityID int64, a web.Auth) (subscription *SubscriptionWithUser, err error) { u, is := a.(*user.User) - if u != nil && !is { + if !is || u == nil { return } diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 98b3fa887..5df2abda1 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -1577,7 +1577,9 @@ func (t *Task) ReadOne(s *xorm.Session, a web.Auth) (err error) { if err != nil && IsErrProjectDoesNotExist(err) { return nil } - t.Subscription = &subs.Subscription + if subs != nil { + t.Subscription = &subs.Subscription + } return }