summaryrefslogtreecommitdiff
path: root/notifications.go
diff options
context:
space:
mode:
Diffstat (limited to 'notifications.go')
-rw-r--r--notifications.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/notifications.go b/notifications.go
index 5061a2a..02d814d 100644
--- a/notifications.go
+++ b/notifications.go
@@ -34,14 +34,14 @@ type NotificationMail interface {
var NotifyMailChannel = make(chan NotificationMail, 1)
func MailNotifier(quitMailNotifier chan int) {
- logger.Infof("Launched mail notifier")
+ log.Info("Launched mail notifier")
for {
select {
case notification := <-NotifyMailChannel:
content := notification.GetNotificationContent()
mailText, err := buildMail(content.template, content.data)
if err != nil {
- logger.Errorf("building mail failed: %s", err)
+ log.Errorf("building mail failed: %v", err)
continue
}
@@ -58,10 +58,10 @@ func MailNotifier(quitMailNotifier chan int) {
d := gomail.NewDialer(config.MailServer.Host, config.MailServer.Port, "", "")
if err := d.DialAndSend(m); err != nil {
- logger.Errorf("sending mail failed: %s", err)
+ log.Errorf("sending mail failed: %v", err)
}
case <-quitMailNotifier:
- logger.Infof("Ending mail notifier")
+ log.Info("Ending mail notifier")
return
}
}
@@ -75,7 +75,10 @@ func buildMail(templateName string, context interface{}) (mailText *bytes.Buffer
}
mailText = bytes.NewBufferString("")
- t.Execute(mailText, context)
+ if err := t.Execute(mailText, context); err != nil {
+ log.Errorf("Failed to execute template %s with context %+v: %v", templateName, context, err)
+ return nil, err
+ }
return
}
@@ -108,11 +111,12 @@ func (n *decisionReplyBase) getSubject() string {
type notificationClosedDecision struct {
notificationBase
decisionReplyBase
- voteSums VoteSums
+ voteSums VoteSums
+ reasoning string
}
-func NewNotificationClosedDecision(decision *Decision, voteSums *VoteSums) NotificationMail {
- notification := &notificationClosedDecision{voteSums: *voteSums}
+func NewNotificationClosedDecision(decision *Decision, voteSums *VoteSums, reasoning string) NotificationMail {
+ notification := &notificationClosedDecision{voteSums: *voteSums, reasoning: reasoning}
notification.decision = *decision
return notification
}
@@ -123,7 +127,8 @@ func (n *notificationClosedDecision) GetNotificationContent() *notificationConte
data: struct {
*Decision
*VoteSums
- }{&n.decision, &n.voteSums},
+ Reasoning string
+ }{&n.decision, &n.voteSums, n.reasoning},
subject: fmt.Sprintf("Re: %s - %s - finalised", n.decision.Tag, n.decision.Title),
headers: n.decisionReplyBase.getHeaders(),
recipients: []recipientData{n.notificationBase.getRecipient()},