Add export ready notification
This commit is contained in:
parent
7f7377085f
commit
238a4387c2
@ -18,13 +18,15 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
"code.vikunja.io/api/pkg/files"
|
||||
"code.vikunja.io/api/pkg/modules/dump"
|
||||
"code.vikunja.io/api/pkg/notifications"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/api/pkg/version"
|
||||
|
||||
"archive/zip"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -80,11 +82,10 @@ func ExportUserData(u *user.User) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// Pack it in a zip file and save it
|
||||
|
||||
// Send a notification
|
||||
|
||||
return nil
|
||||
return notifications.Notify(u, &DataExportReadyNotification{
|
||||
User: u,
|
||||
})
|
||||
}
|
||||
|
||||
func exportListsAndTasks(s *xorm.Session, u *user.User, wr *zip.Writer) (err error) {
|
||||
|
@ -302,3 +302,28 @@ func (n *UserMentionedInTaskNotification) ToDB() interface{} {
|
||||
func (n *UserMentionedInTaskNotification) Name() string {
|
||||
return "task.mentioned"
|
||||
}
|
||||
|
||||
// DataExportReadyNotification represents a DataExportReadyNotification notification
|
||||
type DataExportReadyNotification struct {
|
||||
User *user.User `json:"user"`
|
||||
}
|
||||
|
||||
// ToMail returns the mail notification for DataExportReadyNotification
|
||||
func (n *DataExportReadyNotification) ToMail() *notifications.Mail {
|
||||
return notifications.NewMail().
|
||||
Subject("Your Vikunja Data Export is ready").
|
||||
Greeting("Hi "+n.User.GetName()+",").
|
||||
Line("Your Vikunja Data Export is ready for you to download. Click the button below to download it:").
|
||||
Action("Download", config.ServiceFrontendurl.GetString()+"user/export/download").
|
||||
Line("Have a nice day!")
|
||||
}
|
||||
|
||||
// ToDB returns the DataExportReadyNotification notification in a format which can be saved in the db
|
||||
func (n *DataExportReadyNotification) ToDB() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Name returns the name of the notification
|
||||
func (n *DataExportReadyNotification) Name() string {
|
||||
return "data.export.ready"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user