1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package main
- import (
- "strconv"
- "time"
- notification "imuslab.com/arozos/mod/notification"
- "imuslab.com/arozos/mod/notification/agents/smtpn"
- )
- var notificationQueue *notification.NotificationQueue
- func notificationInit() {
- //Create a new notification agent
- notificationQueue = notification.NewNotificationQueue()
- //Register the notification agents
- //SMTP Mail Sender
- //Load configuration from database
- //Load username and their email from authAgent
- userEmailmap := map[string]string{}
- allRecords := registerHandler.ListAllUserEmails()
- for _, userRercord := range allRecords {
- if userRercord[2].(bool) {
- userEmailmap[userRercord[0].(string)] = userRercord[1].(string)
- }
- }
- //log.Println(userEmailmap)
- smtpAgent := smtpn.Agent{
- Hostname: *host_name,
- SMTPSender: "[email protected]",
- SMTPPassword: "",
- SMTPDomain: "mail.gandi.net",
- SMTPPort: 587,
- UsernameToEmailMap: userEmailmap,
- }
- notificationQueue.RegisterNotificationAgent(smtpAgent)
- //Create and register other notification agents
- go func() {
- time.Sleep(10 * time.Second)
- return
- notificationQueue.BroadcastNotification(¬ification.NotificationPayload{
- ID: strconv.Itoa(int(time.Now().Unix())),
- Title: "Disk SMART Error",
- Message: "This is a testing notification for showcasing a sample email when DISK SMART error was scanned and discovered.<br> Please visit <a href='https://blog.teacat.io'>here</a> for more information.",
- Receiver: []string{"TC"},
- Sender: "SMART Nightly Scanner",
- ReciverAgents: []string{"smtpn"},
- })
- }()
- }
|