1
0

fix(tasks): make sure task deleted notification actually has information about the deleted task

This commit is contained in:
kolaente
2023-06-07 18:14:10 +02:00
parent 456495ec30
commit 1a840c8b87
3 changed files with 16 additions and 3 deletions

View File

@ -298,7 +298,13 @@ func (s *SendTaskDeletedNotification) Handle(msg *message.Message) (err error) {
sess := db.NewSession()
defer sess.Close()
subscribers, err := getSubscribersForEntity(sess, SubscriptionEntityTask, event.Task.ID)
var subscribers []*Subscription
subscribers, err = getSubscribersForEntity(sess, SubscriptionEntityTask, event.Task.ID)
// If the task does not exist and no one has explicitely subscribed to it, we won't find any subscriptions for it.
// Hence, we need to check for subscriptions to the parent project manually.
if err != nil && (IsErrTaskDoesNotExist(err) || IsErrProjectDoesNotExist(err)) {
subscribers, err = getSubscribersForEntity(sess, SubscriptionEntityProject, event.Task.ProjectID)
}
if err != nil {
return err
}