Skip to content

Commit

Permalink
feat: use of markdown in notification messages
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Sep 6, 2023
1 parent c0ab787 commit 676218c
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 195 deletions.
2 changes: 1 addition & 1 deletion api/responders.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type IncidentResponders struct {
type Responder struct {
ID uuid.UUID `json:"id,omitempty"`
Type string `json:"type"`
Properties types.JSONMap `json:"properties" gorm:"type:jsonstringmap;<-:false"`
Properties types.JSONMap `json:"properties" gorm:"<-:false"`
ExternalID string `json:"external_id,omitempty"`
IncidentID uuid.UUID `json:"incident_id,omitempty"`
Incident Incident `json:"incident,omitempty"`
Expand Down
20 changes: 10 additions & 10 deletions events/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,43 +101,43 @@ func defaultTitleAndBody(event string) (title string, body string) {
switch event {
case EventCheckPassed:
title = "Check {{.check.name}} has passed"
body = "Check {{.check.name}} has passed.\n\nReference: {{.permalink}}"
body = "[Reference]({{.permalink}})"

case EventCheckFailed:
title = "Check {{.check.name}} has failed"
body = "Check {{.check.name}} has failed.\n\nReference: {{.permalink}}"
body = "[Reference]({{.permalink}})"

case EventComponentStatusHealthy, EventComponentStatusUnhealthy, EventComponentStatusInfo, EventComponentStatusWarning, EventComponentStatusError:
title = "Component {{.component.name}} status updated to {{.component.status}}"
body = "Component {{.component.name}} status updated to {{.component.status}}\n\nReference: {{.permalink}}"
body = "Component {{.component.name}} status updated to {{.component.status}}\n\n[Reference]({{.permalink}})"

case EventIncidentCommentAdded:
title = "{{.author.name}} left a comment on {{.incident.incident_id}}: {{.incident.title}}"
body = "{{.comment.comment}}\n\nReference: {{.permalink}}"
body = "{{.comment.comment}}\n\n[Reference]({{.permalink}})"

case EventIncidentCreated:
title = "{{.incident.incident_id}}: {{.incident.title}} ({{.incident.severity}}) created"
body = "Type: {{.incident.type}}\n\nReference: {{.permalink}}"
body = "Type: {{.incident.type}}\n\n[Reference]({{.permalink}})"

case EventIncidentDODAdded:
title = "Definition of Done added | {{.incident.incident_id}}: {{.incident.title}}"
body = "Evidence: {{.evidence.description}}\n\nReference: {{.permalink}}"
body = "Evidence: {{.evidence.description}}\n\n[Reference]({{.permalink}})"

case EventIncidentDODPassed, EventIncidentDODRegressed:
title = "Definition of Done {{if .evidence.done}}passed{{else}}regressed{{end}} | {{.incident.incident_id}}: {{.incident.title}}"
body = "Evidence: {{.evidence.description}}\nHypothesis: {{.hypothesis.title}}\n\nReference: {{.permalink}}"
body = "Evidence: {{.evidence.description}}\nHypothesis: {{.hypothesis.title}}\n\n[Reference]({{.permalink}})"

case EventIncidentResponderAdded:
title = "New responder added to {{.incident.incident_id}}: {{.incident.title}}"
body = "Responder {{.responder.name}}\n\nReference: {{.permalink}}"
body = "Responder {{.responder.name}}\n\n[Reference]({{.permalink}})"

case EventIncidentResponderRemoved:
title = "Responder removed from {{.incident.incident_id}}: {{.incident.title}}"
body = "Responder {{.responder.name}}\n\nReference: {{.permalink}}"
body = "Responder {{.responder.name}}\n\n[Reference]({{.permalink}})"

case EventIncidentStatusCancelled, EventIncidentStatusClosed, EventIncidentStatusInvestigating, EventIncidentStatusMitigated, EventIncidentStatusOpen, EventIncidentStatusResolved:
title = "{{.incident.title}} status updated"
body = "New Status: {{.incident.status}}\n\nReference: {{.permalink}}"
body = "New Status: {{.incident.status}}\n\n[Reference]({{.permalink}})"

case EventTeamUpdate, EventTeamDelete, EventNotificationUpdate, EventNotificationDelete, EventPlaybookSpecApprovalUpdated, EventPlaybookApprovalInserted:
// Not applicable
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ go 1.20
require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0
github.com/MicahParks/keyfunc v1.9.0
github.com/adityathebe/go-strip-markdown/v2 v2.0.1
github.com/andygrunwald/go-jira v1.16.0
github.com/casbin/casbin/v2 v2.73.0
github.com/casbin/gorm-adapter/v3 v3.18.0
github.com/containrrr/shoutrrr v0.7.1
github.com/containrrr/shoutrrr v0.8.0
github.com/fergusstrange/embedded-postgres v1.23.0
github.com/flanksource/commons v1.11.0
github.com/flanksource/duty v1.0.169
github.com/flanksource/gomplate/v3 v3.20.12
github.com/flanksource/kopper v1.0.6
github.com/gomarkdown/markdown v0.0.0-20230716120725-531d2d74bc12
github.com/google/cel-go v0.17.6
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.1
Expand Down Expand Up @@ -206,7 +208,7 @@ require (
golang.org/x/crypto v0.12.0
golang.org/x/net v0.14.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
Expand Down
Loading

0 comments on commit 676218c

Please sign in to comment.