|
|
@@ -40,7 +40,7 @@ func (s *IncidentNotifier) NotifyNew(incident *types.Incident, url string) error
|
|
|
sgMail := &mail.SGMailV3{
|
|
|
Personalizations: []*mail.Personalization{
|
|
|
{
|
|
|
- To: addrs,
|
|
|
+ BCC: addrs,
|
|
|
DynamicTemplateData: map[string]interface{}{
|
|
|
"incident_text": incident.Summary,
|
|
|
"app_url": url,
|
|
|
@@ -52,7 +52,7 @@ func (s *IncidentNotifier) NotifyNew(incident *types.Incident, url string) error
|
|
|
},
|
|
|
From: &mail.Email{
|
|
|
Address: s.opts.SenderEmail,
|
|
|
- Name: "Porter",
|
|
|
+ Name: "Porter Notifications",
|
|
|
},
|
|
|
TemplateID: s.opts.IncidentAlertTemplateID,
|
|
|
}
|
|
|
@@ -65,5 +65,40 @@ func (s *IncidentNotifier) NotifyNew(incident *types.Incident, url string) error
|
|
|
}
|
|
|
|
|
|
func (s *IncidentNotifier) NotifyResolved(incident *types.Incident, url string) error {
|
|
|
- return nil
|
|
|
+ request := sendgrid.GetRequest(s.opts.APIKey, "/v3/mail/send", "https://api.sendgrid.com")
|
|
|
+ request.Method = "POST"
|
|
|
+
|
|
|
+ addrs := make([]*mail.Email, 0)
|
|
|
+
|
|
|
+ for _, user := range s.opts.Users {
|
|
|
+ addrs = append(addrs, &mail.Email{
|
|
|
+ Address: user.Email,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ sgMail := &mail.SGMailV3{
|
|
|
+ Personalizations: []*mail.Personalization{
|
|
|
+ {
|
|
|
+ BCC: addrs,
|
|
|
+ DynamicTemplateData: map[string]interface{}{
|
|
|
+ "incident_resolved_text": fmt.Sprintf("[Resolved] The incident for application %s has been resolved. The incident text was:\n\n:%s", incident.ReleaseName, incident.Summary),
|
|
|
+ "app_url": url,
|
|
|
+ "subject": fmt.Sprintf("[Resolved] The incident for application %s has been resolved", incident.ReleaseName),
|
|
|
+ "preheader": incident.Summary,
|
|
|
+ "resolved_at": fmt.Sprintf("%v", incident.UpdatedAt),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ From: &mail.Email{
|
|
|
+ Address: s.opts.SenderEmail,
|
|
|
+ Name: "Porter Notifications",
|
|
|
+ },
|
|
|
+ TemplateID: s.opts.IncidentResolvedTemplateID,
|
|
|
+ }
|
|
|
+
|
|
|
+ request.Body = mail.GetRequestBody(sgMail)
|
|
|
+
|
|
|
+ _, err := sendgrid.API(request)
|
|
|
+
|
|
|
+ return err
|
|
|
}
|