add email notification

This commit is contained in:
GotPPay
2018-05-28 15:16:10 +02:00
parent db4ffe6965
commit fc3029c6c3

View File

@@ -16,6 +16,11 @@ import (
"github.com/labstack/echo"
)
const (
notificationEmailSubject = "Registration sucessful"
notificationEmailBody = "You have registered as a Visit Reporter for CHM NEMT.\nLogin: https://portal.bcbsinstitute.com\nReset PW: https://portal.bcbsinstitute.com/forgot"
)
var (
instance *controller
once sync.Once
@@ -115,5 +120,15 @@ func (c *controller) handle(ctx echo.Context) error {
return routeutils.HandleAPIError(ctx, err)
}
fmt.Println("\n\nSend email\n\n")
//Send email notification to Authorized user
notifications := make([]viewmodel.Notification, 1)
notifications = append(notifications, viewmodel.Notification{Type: "email", From: c.cfg.Email.Sender, To: *user.Email, Subject: notificationEmailSubject, Message: notificationEmailBody})
notifications, err = c.svc.Notification.SendNotifications(notifications)
if err != nil {
return routeutils.HandleAPIError(ctx, err)
}
return routeutils.ResponseAPIOK(ctx, user)
}