Add deleted notification
This commit is contained in:
parent
bab58fda8d
commit
1cf420b835
|
@ -18,6 +18,7 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.vikunja.io/api/pkg/notifications"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.vikunja.io/api/pkg/cron"
|
"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)
|
_, 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) {
|
func ensureNamespaceAdminUser(s *xorm.Session, n *Namespace) (hadUsers bool, err error) {
|
||||||
|
|
|
@ -242,5 +242,30 @@ func (n *AccountDeletionNotification) ToDB() interface{} {
|
||||||
|
|
||||||
// Name returns the name of the notification
|
// Name returns the name of the notification
|
||||||
func (n *AccountDeletionNotification) Name() string {
|
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"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue