Add deleted notification

This commit is contained in:
kolaente 2021-08-09 16:57:20 +02:00
parent bab58fda8d
commit 1cf420b835
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 32 additions and 2 deletions

View File

@ -18,6 +18,7 @@
package models
import (
"code.vikunja.io/api/pkg/notifications"
"time"
"code.vikunja.io/api/pkg/cron"
@ -164,7 +165,11 @@ func DeleteUser(s *xorm.Session, u *user.User) (err error) {
}
_, err = s.Where("id = ?", u.ID).Delete(u)
return
if err != nil {
return err
}
return notifications.Notify(u, &user.AccountDeletedNotification{})
}
func ensureNamespaceAdminUser(s *xorm.Session, n *Namespace) (hadUsers bool, err error) {

View File

@ -242,5 +242,30 @@ func (n *AccountDeletionNotification) ToDB() interface{} {
// Name returns the name of the notification
func (n *AccountDeletionNotification) Name() string {
return "usr.deletion"
return "user.deletion"
}
// AccountDeletedNotification represents a AccountDeletedNotification notification
type AccountDeletedNotification struct {
User *User
}
// ToMail returns the mail notification for AccountDeletedNotification
func (n *AccountDeletedNotification) ToMail() *notifications.Mail {
return notifications.NewMail().
Subject("Your Vikunja Account has been deleted").
Greeting("Hi " + n.User.GetName() + ",").
Line("As requested, we've deleted your Vikunja account.").
Line("This deletion is permanent. If did not create a backup and need your data back now, talk to your administrator.").
Line("Have a nice day!")
}
// ToDB returns the AccountDeletedNotification notification in a format which can be saved in the db
func (n *AccountDeletedNotification) ToDB() interface{} {
return nil
}
// Name returns the name of the notification
func (n *AccountDeletedNotification) Name() string {
return "user.deleted"
}