c24c19b120
- Add notifications for campaign state change - Add notifications for import state change Related changes. - Add a new 'templates' directory with HTML templates - Move the static campaign template as a .tpl file into it - Change Messenger.Push() to accept multiple recipients - Change exhaustCampaign()'s behaviour to pass metadata to admin emails
32 lines
655 B
Go
32 lines
655 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())
|
|
if err != nil {
|
|
app.Logger.Printf("error sending admin notification (%s): %v", subject, err)
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|