From c8f7a57566be1e9198afae52c57cfc4bc96b5db7 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 3 Sep 2024 22:37:53 +0200 Subject: [PATCH] fix(subscription): always return task subscription when subscribed to task and project (cherry picked from commit 115d1c3618811560b4f2c87d764da196bafc1c06) --- pkg/models/subscription.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/models/subscription.go b/pkg/models/subscription.go index e775ce81c..3ff498e58 100644 --- a/pkg/models/subscription.go +++ b/pkg/models/subscription.go @@ -242,6 +242,15 @@ func GetSubscriptions(s *xorm.Session, entityType SubscriptionEntityType, entity return nil, err } + for _, sub := range subs { + // The subscriptions might also contain the immediate parent subscription, if that exists. + // This loop makes sure to only return the task subscription if it exists. The fallback + // happens in the next if after the loop. + if sub.EntityID == entityID && sub.EntityType == SubscriptionEntityTask { + return []*Subscription{sub}, nil + } + } + if len(subs) > 0 { return subs, nil }