Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
}
35 changes: 27 additions & 8 deletions notification/webhook/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"encoding/json"
"fmt"
"net/http"
"strings"
"time"

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

// POSTDataAlertBundle represents fields in outgoing alert bundle notification.
Expand All @@ -36,14 +38,21 @@
ServiceID string
ServiceName string
Count int
AlertURL 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
AlertURL string
}

// POSTDataAlertStatusBundle represents fields in outgoing alert status bundle notification.
Expand All @@ -53,6 +62,7 @@
AlertID int
LogEntry string
Count int
AlertURL string
}

// POSTDataVerification represents fields in outgoing verification notification.
Expand Down Expand Up @@ -97,6 +107,7 @@
func (s *Sender) SendMessage(ctx context.Context, msg notification.Message) (*notification.SentMessage, error) {
cfg := config.FromContext(ctx)
var payload interface{}
pubURL := strings.TrimSuffix(cfg.PublicURL(), "/")

Check failure on line 110 in notification/webhook/sender.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

declared and not used: pubURL

Check failure on line 110 in notification/webhook/sender.go

View workflow job for this annotation

GitHub Actions / lint

declared and not used: pubURL (typecheck)
switch m := msg.(type) {
case notification.Test:
payload = POSTDataTest{
Expand All @@ -119,6 +130,7 @@
ServiceID: m.ServiceID,
ServiceName: m.ServiceName,
Meta: m.Meta,
AlertURL: cfg.CallbackURL(fmt.Sprintf("/alerts/%d", m.AlertID)),
}
case notification.AlertBundle:
payload = POSTDataAlertBundle{
Expand All @@ -127,13 +139,20 @@
ServiceID: m.ServiceID,
ServiceName: m.ServiceName,
Count: m.Count,
AlertURL: cfg.CallbackURL(fmt.Sprintf("/services/%s/alerts", m.ServiceID)),
}
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,
AlertURL: cfg.CallbackURL(fmt.Sprintf("/alerts/%d", m.AlertID)),
}
case notification.ScheduleOnCallUsers:
// We use types defined in this package to insulate against unintended API
Expand Down
Loading