From 69bd023b62687b2ab5de374c68377d4bb08af57c Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 7 Jun 2023 18:17:08 +0200 Subject: [PATCH] fix(tasks): return a correct task identifier if the list does not have a good one set --- pkg/models/notifications.go | 4 ++-- pkg/models/tasks.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/models/notifications.go b/pkg/models/notifications.go index c43f15ab3ea..e5017d92a3c 100644 --- a/pkg/models/notifications.go +++ b/pkg/models/notifications.go @@ -136,8 +136,8 @@ type TaskDeletedNotification struct { // ToMail returns the mail notification for TaskDeletedNotification func (n *TaskDeletedNotification) ToMail() *notifications.Mail { return notifications.NewMail(). - Subject(n.Task.Title + "(" + n.Task.GetFullIdentifier() + ")" + " has been deleted"). - Line(n.Doer.GetName() + " has deleted the task " + n.Task.Title + "(" + n.Task.GetFullIdentifier() + ")") + Subject(n.Task.Title + " (" + n.Task.GetFullIdentifier() + ")" + " has been deleted"). + Line(n.Doer.GetName() + " has deleted the task " + n.Task.Title + " (" + n.Task.GetFullIdentifier() + ")") } // ToDB returns the TaskDeletedNotification notification in a format which can be saved in the db diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 23d07141ce0..65b4b02c2dc 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -151,6 +151,9 @@ func (*Task) TableName() string { // GetFullIdentifier returns the task identifier if the task has one and the index prefixed with # otherwise. func (t *Task) GetFullIdentifier() string { if t.Identifier != "" { + if strings.HasPrefix(t.Identifier, "-") { + return "#" + strings.TrimPrefix(t.Identifier, "-") + } return t.Identifier }