fix(tasks): make sure task deleted notification actually has information about the deleted task
This commit is contained in:
parent
456495ec30
commit
1a840c8b87
@ -298,7 +298,13 @@ func (s *SendTaskDeletedNotification) Handle(msg *message.Message) (err error) {
|
|||||||
sess := db.NewSession()
|
sess := db.NewSession()
|
||||||
defer sess.Close()
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ type TaskDeletedNotification struct {
|
|||||||
// ToMail returns the mail notification for TaskDeletedNotification
|
// ToMail returns the mail notification for TaskDeletedNotification
|
||||||
func (n *TaskDeletedNotification) ToMail() *notifications.Mail {
|
func (n *TaskDeletedNotification) ToMail() *notifications.Mail {
|
||||||
return notifications.NewMail().
|
return notifications.NewMail().
|
||||||
Subject(n.Task.Title + "(" + n.Task.GetFullIdentifier() + ")" + " has been delete").
|
Subject(n.Task.Title + "(" + n.Task.GetFullIdentifier() + ")" + " has been deleted").
|
||||||
Line(n.Doer.GetName() + " has deleted the task " + n.Task.Title + "(" + n.Task.GetFullIdentifier() + ")")
|
Line(n.Doer.GetName() + " has deleted the task " + n.Task.Title + "(" + n.Task.GetFullIdentifier() + ")")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1603,6 +1603,13 @@ func updateTaskLastUpdated(s *xorm.Session, task *Task) error {
|
|||||||
// @Router /tasks/{ID} [delete]
|
// @Router /tasks/{ID} [delete]
|
||||||
func (t *Task) Delete(s *xorm.Session, a web.Auth) (err error) {
|
func (t *Task) Delete(s *xorm.Session, a web.Auth) (err error) {
|
||||||
|
|
||||||
|
// duplicate the task for the event
|
||||||
|
fullTask := &Task{ID: t.ID}
|
||||||
|
err = fullTask.ReadOne(s, a)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if _, err = s.ID(t.ID).Delete(Task{}); err != nil {
|
if _, err = s.ID(t.ID).Delete(Task{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1657,7 +1664,7 @@ func (t *Task) Delete(s *xorm.Session, a web.Auth) (err error) {
|
|||||||
|
|
||||||
doer, _ := user.GetFromAuth(a)
|
doer, _ := user.GetFromAuth(a)
|
||||||
err = events.Dispatch(&TaskDeletedEvent{
|
err = events.Dispatch(&TaskDeletedEvent{
|
||||||
Task: t,
|
Task: fullTask,
|
||||||
Doer: doer,
|
Doer: doer,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user