Add account deletion notifications

This commit is contained in:
kolaente 2021-08-02 08:04:12 +02:00
parent f237afd2ac
commit 5e54f90589
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 57 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package user
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/notifications"
"strconv"
)
// EmailConfirmNotification represents a EmailConfirmNotification notification
@ -186,3 +187,59 @@ func (n *FailedLoginAttemptNotification) ToDB() interface{} {
func (n *FailedLoginAttemptNotification) Name() string {
return "failed.login.attempt"
}
// AccountDeletionConfirmNotification represents a AccountDeletionConfirmNotification notification
type AccountDeletionConfirmNotification struct {
User *User
ConfirmToken string
}
// ToMail returns the mail notification for AccountDeletionConfirmNotification
func (n *AccountDeletionConfirmNotification) ToMail() *notifications.Mail {
return notifications.NewMail().
Subject("Please confirm the deletion of your Vikunja account").
Greeting("Hi "+n.User.GetName()+",").
Line("You have requested the deletion of your account. To confirm this, please click the link below:").
Action("Confirm the deletion of my account", config.ServiceFrontendurl.GetString()+"?accountDeletionConfirm="+n.ConfirmToken).
Line("Once you confirm the deletion we will schedule the deletion of your account in three days and send you another email until then.").
Line("If you did not requested the deletion or changed your mind, you can simply ignore this email.").
Line("Have a nice day!")
}
// ToDB returns the AccountDeletionConfirmNotification notification in a format which can be saved in the db
func (n *AccountDeletionConfirmNotification) ToDB() interface{} {
return nil
}
// Name returns the name of the notification
func (n *AccountDeletionConfirmNotification) Name() string {
return "user.deletion.confirm"
}
// AccountDeletionNotification represents a AccountDeletionNotification notification
type AccountDeletionNotification struct {
User *User
NotificationNumber int
}
// ToMail returns the mail notification for AccountDeletionNotification
func (n *AccountDeletionNotification) ToMail() *notifications.Mail {
return notifications.NewMail().
Subject("Your Vikunja account will be deleted in "+strconv.Itoa(n.NotificationNumber)+" days").
Greeting("Hi "+n.User.GetName()+",").
Line("You recently requested the deletion of your Vikunja account.").
Line("We will delete your account in "+strconv.Itoa(n.NotificationNumber)+" days.").
Line("If you changed your mind, simply click the link below to cancel the deletion:").
Action("Abort the deletion", config.ServiceFrontendurl.GetString()).
Line("Have a nice day!")
}
// ToDB returns the AccountDeletionNotification notification in a format which can be saved in the db
func (n *AccountDeletionNotification) ToDB() interface{} {
return nil
}
// Name returns the name of the notification
func (n *AccountDeletionNotification) Name() string {
return "usr.deletion"
}