mirror of https://github.com/statping/statping
removed notifier exports
parent
7a859180fe
commit
c539c72c60
|
@ -28,7 +28,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
TEMPLATE = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
mainEmailTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
@ -183,7 +183,7 @@ func (u *email) OnFailure(s *types.Service, f *types.Failure) {
|
|||
email := &emailOutgoing{
|
||||
To: emailer.GetValue("var2"),
|
||||
Subject: fmt.Sprintf("Service %v is Failing", s.Name),
|
||||
Template: TEMPLATE,
|
||||
Template: mainEmailTemplate,
|
||||
Data: interface{}(s),
|
||||
From: emailer.GetValue("var1"),
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ func (u *email) OnSuccess(s *types.Service) {
|
|||
email := &emailOutgoing{
|
||||
To: emailer.GetValue("var2"),
|
||||
Subject: fmt.Sprintf("Service %v is Back Online", s.Name),
|
||||
Template: TEMPLATE,
|
||||
Template: mainEmailTemplate,
|
||||
Data: interface{}(s),
|
||||
From: emailer.GetValue("var1"),
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ func TestEmailNotifier(t *testing.T) {
|
|||
testEmail = &emailOutgoing{
|
||||
To: emailer.GetValue("var2"),
|
||||
Subject: fmt.Sprintf("Service %v is Failing", TestService.Name),
|
||||
Template: TEMPLATE,
|
||||
Template: mainEmailTemplate,
|
||||
Data: TestService,
|
||||
From: emailer.GetValue("var1"),
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
LINE_NOTIFY_METHOD = "line notify"
|
||||
lineNotifyMethod = "line notify"
|
||||
)
|
||||
|
||||
type lineNotifier struct {
|
||||
|
@ -34,7 +34,7 @@ type lineNotifier struct {
|
|||
}
|
||||
|
||||
var lineNotify = &lineNotifier{¬ifier.Notification{
|
||||
Method: LINE_NOTIFY_METHOD,
|
||||
Method: lineNotifyMethod,
|
||||
Title: "LINE Notify",
|
||||
Description: "LINE Notify will send notifications to your LINE Notify account when services are offline or online. Baed on the <a href=\"https://notify-bot.line.me/doc/en/\">LINE Notify API</a>.",
|
||||
Author: "Kanin Peanviriyakulkit",
|
||||
|
|
|
@ -28,10 +28,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
SLACK_METHOD = "slack"
|
||||
FAILING_TEMPLATE = `{ "attachments": [ { "fallback": "Service {{.Service.Name}} - is currently failing", "text": "<{{.Service.Domain}}|{{.Service.Name}}> - Your Statup service '{{.Service.Name}}' has just received a Failure notification with a HTTP Status code of {{.Service.LastStatusCode}}.", "fields": [ { "title": "Expected", "value": "{{.Service.Expected}}", "short": true }, { "title": "Status Code", "value": "{{.Service.LastStatusCode}}", "short": true } ], "color": "#FF0000", "thumb_url": "https://statup.io", "footer": "Statup", "footer_icon": "https://img.cjx.io/statuplogo32.png" } ] }`
|
||||
SUCCESS_TEMPLATE = `{ "attachments": [ { "fallback": "Service {{.Service.Name}} - is now back online", "text": "<{{.Service.Domain}}|{{.Service.Name}}> - Your Statup service '{{.Service.Name}}' has just received a Failure notification.", "fields": [ { "title": "Issue", "value": "Awesome Project", "short": true }, { "title": "Status Code", "value": "{{.Service.LastStatusCode}}", "short": true } ], "color": "#00FF00", "thumb_url": "https://statup.io", "footer": "Statup", "footer_icon": "https://img.cjx.io/statuplogo32.png" } ] }`
|
||||
SLACK_TEXT = `{"text":"{{.}}"}`
|
||||
slackMethod = "slack"
|
||||
failingTemplate = `{ "attachments": [ { "fallback": "Service {{.Service.Name}} - is currently failing", "text": "<{{.Service.Domain}}|{{.Service.Name}}> - Your Statup service '{{.Service.Name}}' has just received a Failure notification with a HTTP Status code of {{.Service.LastStatusCode}}.", "fields": [ { "title": "Expected", "value": "{{.Service.Expected}}", "short": true }, { "title": "Status Code", "value": "{{.Service.LastStatusCode}}", "short": true } ], "color": "#FF0000", "thumb_url": "https://statup.io", "footer": "Statup", "footer_icon": "https://img.cjx.io/statuplogo32.png" } ] }`
|
||||
successTemplate = `{ "attachments": [ { "fallback": "Service {{.Service.Name}} - is now back online", "text": "<{{.Service.Domain}}|{{.Service.Name}}> - Your Statup service '{{.Service.Name}}' has just received a Failure notification.", "fields": [ { "title": "Issue", "value": "Awesome Project", "short": true }, { "title": "Status Code", "value": "{{.Service.LastStatusCode}}", "short": true } ], "color": "#00FF00", "thumb_url": "https://statup.io", "footer": "Statup", "footer_icon": "https://img.cjx.io/statuplogo32.png" } ] }`
|
||||
slackText = `{"text":"{{.}}"}`
|
||||
)
|
||||
|
||||
type slack struct {
|
||||
|
@ -39,7 +39,7 @@ type slack struct {
|
|||
}
|
||||
|
||||
var slacker = &slack{¬ifier.Notification{
|
||||
Method: SLACK_METHOD,
|
||||
Method: slackMethod,
|
||||
Title: "slack",
|
||||
Description: "Send notifications to your slack channel when a service is offline. Insert your Incoming webhooker URL for your channel to receive notifications. Based on the <a href=\"https://api.slack.com/incoming-webhooks\">slack API</a>.",
|
||||
Author: "Hunter Long",
|
||||
|
@ -116,10 +116,10 @@ func (u *slack) OnTest() error {
|
|||
func (u *slack) OnFailure(s *types.Service, f *types.Failure) {
|
||||
message := slackMessage{
|
||||
Service: s,
|
||||
Template: FAILING_TEMPLATE,
|
||||
Template: failingTemplate,
|
||||
Time: time.Now().Unix(),
|
||||
}
|
||||
parseSlackMessage(FAILING_TEMPLATE, message)
|
||||
parseSlackMessage(failingTemplate, message)
|
||||
u.Online = false
|
||||
}
|
||||
|
||||
|
@ -128,10 +128,10 @@ func (u *slack) OnSuccess(s *types.Service) {
|
|||
if !u.Online {
|
||||
message := slackMessage{
|
||||
Service: s,
|
||||
Template: SUCCESS_TEMPLATE,
|
||||
Template: successTemplate,
|
||||
Time: time.Now().Unix(),
|
||||
}
|
||||
parseSlackMessage(SUCCESS_TEMPLATE, message)
|
||||
parseSlackMessage(successTemplate, message)
|
||||
}
|
||||
u.Online = true
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ func TestSlackNotifier(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("slack parse message", func(t *testing.T) {
|
||||
err := parseSlackMessage(SLACK_TEXT, "this is a test!")
|
||||
err := parseSlackMessage(slackText, "this is a test!")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 1, len(slacker.Queue))
|
||||
})
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
WEBHOOK_METHOD = "webhook"
|
||||
webhookMethod = "webhook"
|
||||
)
|
||||
|
||||
type webhooker struct {
|
||||
|
@ -36,7 +36,7 @@ type webhooker struct {
|
|||
}
|
||||
|
||||
var webhook = &webhooker{¬ifier.Notification{
|
||||
Method: WEBHOOK_METHOD,
|
||||
Method: webhookMethod,
|
||||
Title: "HTTP webhooker",
|
||||
Description: "Send a custom HTTP request to a specific URL with your own body, headers, and parameters",
|
||||
Author: "Hunter Long",
|
||||
|
|
Loading…
Reference in New Issue