listmonk/notifications.go
Kailash Nadh 3b7902802e Add data privacy export / wipe features (aimed at GDPR compliance).
- Toggle options to enable self-service data export and wipe
  options on the public unsubscription page. Subscribers can get
  a copy of all data on them e-mailed to them as JSON, or
  instantly wipe all their data.
- Refactor "unsubscribe" pages and URIs to "subscription".
- Add export icon to subscriber admin view.
2019-07-21 19:21:23 +05:30

48 lines
999 B
Go

package main
import (
"bytes"
)
const (
notifTplImport = "import-status"
notifTplCampaign = "campaign-status"
)
// sendNotification sends out an e-mail notification to admins.
func sendNotification(tpl, subject string, data map[string]interface{}, app *App) error {
data["RootURL"] = app.Constants.RootURL
var b bytes.Buffer
err := app.NotifTpls.ExecuteTemplate(&b, tpl, data)
if err != nil {
return err
}
err = app.Messenger.Push(app.Constants.FromEmail,
app.Constants.NotifyEmails,
subject,
b.Bytes(),
nil)
if err != nil {
app.Logger.Printf("error sending admin notification (%s): %v", subject, err)
return err
}
return nil
}
func getNotificationTemplate(tpl string, data map[string]interface{}, app *App) ([]byte, error) {
if data == nil {
data = make(map[string]interface{})
}
data["RootURL"] = app.Constants.RootURL
var b bytes.Buffer
err := app.NotifTpls.ExecuteTemplate(&b, tpl, data)
if err != nil {
return nil, err
}
return b.Bytes(), err
}