Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Patches are welcome, but we ask that any significant change start as an [issue](

More information is available for [complex features](./docs/complex-features.md).

Be sure to run `make check` and tests before opening a PR to catch common errors.
Be sure to run `make check` and `make test` before opening a PR to catch common errors.

### UI Change Guidelines

Expand Down
10 changes: 10 additions & 0 deletions engine/sendmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ func (p *Engine) sendMessage(ctx context.Context, msg *message.Message) (*notifi
if stat == nil {
return nil, fmt.Errorf("could not find original notification for alert %d to %s", msg.AlertID, msg.Dest.String())
}
name, _, err := p.a.ServiceInfo(ctx, a.ServiceID)
if err != nil {
return nil, errors.Wrap(err, "lookup service info")
}
meta, err := p.a.Metadata(ctx, p.b.db, msg.AlertID)
if err != nil {
return nil, errors.Wrap(err, "lookup alert metadata")
}

var status notification.AlertState
switch e.Type() {
Expand All @@ -124,6 +132,8 @@ func (p *Engine) sendMessage(ctx context.Context, msg *message.Message) (*notifi
Details: a.Details,
NewAlertState: status,
OriginalStatus: *stat,
ServiceName: name,
Meta: meta,
}
case notification.MessageTypeTest:
notifMsg = notification.Test{
Expand Down
15 changes: 12 additions & 3 deletions notification/nfymsg/msgalertstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@ const (
type AlertStatus struct {
Base

AlertID int
LogEntry string
ServiceID string
AlertID int

// Summary of the alert that this status is in regards to.
Summary string

// Details of the alert that this status is in regards to.
Details string

ServiceID string

// ServiceName of the alert that this status is in regards to.
ServiceName string

// Meta contains key/value pairs associated with the alert.
Meta map[string]string

// OriginalStatus is the status of the first Alert notification to this Dest for this AlertID.
OriginalStatus SendResult

// NewAlertState contains the most recent state of the alert.
NewAlertState AlertState

LogEntry string
}
45 changes: 32 additions & 13 deletions notification/webhook/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"
"time"

"github.com/target/goalert/config"
Expand All @@ -27,6 +28,7 @@ type POSTDataAlert struct {
ServiceID string
ServiceName string
Meta map[string]string
PublicURL string
}

// POSTDataAlertBundle represents fields in outgoing alert bundle notification.
Expand All @@ -36,23 +38,31 @@ type POSTDataAlertBundle struct {
ServiceID string
ServiceName string
Count int
PublicURL string
}

// POSTDataAlertStatus represents fields in outgoing alert status notification.
type POSTDataAlertStatus struct {
AppName string
Type string
AlertID int
LogEntry string
AppName string
Type string
AlertID int
Summary string
Details string
ServiceID string
ServiceName string
Meta map[string]string
LogEntry string
PublicURL string
}

// POSTDataAlertStatusBundle represents fields in outgoing alert status bundle notification.
type POSTDataAlertStatusBundle struct {
AppName string
Type string
AlertID int
LogEntry string
Count int
AppName string
Type string
AlertID int
LogEntry string
Count int
PublicURL string
}

// POSTDataVerification represents fields in outgoing verification notification.
Expand Down Expand Up @@ -97,6 +107,7 @@ var _ nfydest.MessageSender = &Sender{}
func (s *Sender) SendMessage(ctx context.Context, msg notification.Message) (*notification.SentMessage, error) {
cfg := config.FromContext(ctx)
var payload interface{}
pubURL := strings.TrimRight(cfg.General.PublicURL, "/")
switch m := msg.(type) {
case notification.Test:
payload = POSTDataTest{
Expand All @@ -119,6 +130,7 @@ func (s *Sender) SendMessage(ctx context.Context, msg notification.Message) (*no
ServiceID: m.ServiceID,
ServiceName: m.ServiceName,
Meta: m.Meta,
PublicURL: pubURL,
}
case notification.AlertBundle:
payload = POSTDataAlertBundle{
Expand All @@ -127,13 +139,20 @@ func (s *Sender) SendMessage(ctx context.Context, msg notification.Message) (*no
ServiceID: m.ServiceID,
ServiceName: m.ServiceName,
Count: m.Count,
PublicURL: pubURL,
}
case notification.AlertStatus:
payload = POSTDataAlertStatus{
AppName: cfg.ApplicationName(),
Type: "AlertStatus",
AlertID: m.AlertID,
LogEntry: m.LogEntry,
AppName: cfg.ApplicationName(),
Type: "AlertStatus",
Details: m.Details,
AlertID: m.AlertID,
Summary: m.Summary,
ServiceID: m.ServiceID,
ServiceName: m.ServiceName,
Meta: m.Meta,
LogEntry: m.LogEntry,
PublicURL: pubURL,
}
case notification.ScheduleOnCallUsers:
// We use types defined in this package to insulate against unintended API
Expand Down
Loading