1
0

Improve duration format of overdue tasks in reminders

This commit is contained in:
kolaente
2021-04-18 14:25:50 +02:00
parent 410a7426cf
commit 7ff7b0d743
5 changed files with 135 additions and 213 deletions

View File

@ -22,6 +22,8 @@ import (
"strings"
"time"
"code.vikunja.io/api/pkg/utils"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/notifications"
"code.vikunja.io/api/pkg/user"
@ -194,10 +196,11 @@ type UndoneTaskOverdueNotification struct {
// ToMail returns the mail notification for UndoneTaskOverdueNotification
func (n *UndoneTaskOverdueNotification) ToMail() *notifications.Mail {
until := time.Until(n.Task.DueDate).Round(1*time.Hour) * -1
return notifications.NewMail().
Subject(`Task "`+n.Task.Title+`" is overdue`).
Greeting("Hi "+n.User.GetName()+",").
Line(`This is a friendly reminder of the task "`+n.Task.Title+`" which is overdue since `+time.Until(n.Task.DueDate).String()+` and not yet done.`).
Line(`This is a friendly reminder of the task "`+n.Task.Title+`" which is overdue since `+utils.HumanizeDuration(until)+` and not yet done.`).
Action("Open Task", config.ServiceFrontendurl.GetString()+"tasks/"+strconv.FormatInt(n.Task.ID, 10)).
Line("Have a nice day!")
}