mirror of https://github.com/statping/statping
Add Email, Mobile and Discord Online Messages
parent
c9f140f2dc
commit
df3eb914ed
|
@ -21,6 +21,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/core"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"strings"
|
||||
|
@ -77,7 +78,13 @@ func (u *discord) OnFailure(s *types.Service, f *types.Failure) {
|
|||
func (u *discord) OnSuccess(s *types.Service) {
|
||||
if !s.Online {
|
||||
u.ResetUniqueQueue(fmt.Sprintf("service_%v", s.Id))
|
||||
msg := fmt.Sprintf(`{"content": "Your service '%v' is back online!"}`, s.Name)
|
||||
var msg interface{}
|
||||
if core.CoreApp.UpdateNotify.Bool {
|
||||
msg = fmt.Sprintf(`{"content": "%s"}`, core.ReturnService(s).SmallText())
|
||||
} else {
|
||||
msg = fmt.Sprintf(`{"content": "Your service '%v' is back online!"}`, s.Name)
|
||||
}
|
||||
|
||||
u.AddQueue(fmt.Sprintf("service_%v", s.Id), msg)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/go-mail/mail"
|
||||
"github.com/hunterlong/statping/core"
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
|
@ -199,10 +200,17 @@ func (u *email) OnFailure(s *types.Service, f *types.Failure) {
|
|||
// OnSuccess will trigger successful service
|
||||
func (u *email) OnSuccess(s *types.Service) {
|
||||
if !s.Online {
|
||||
var msg string
|
||||
if core.CoreApp.UpdateNotify.Bool {
|
||||
msg = core.ReturnService(s).SmallText()
|
||||
} else {
|
||||
msg = fmt.Sprintf("Service %v is Back Online", s.Name)
|
||||
}
|
||||
|
||||
u.ResetUniqueQueue(fmt.Sprintf("service_%v", s.Id))
|
||||
email := &emailOutgoing{
|
||||
To: u.Var2,
|
||||
Subject: fmt.Sprintf("Service %v is Back Online", s.Name),
|
||||
Subject: msg,
|
||||
Template: mainEmailTemplate,
|
||||
Data: interface{}(s),
|
||||
From: u.Var1,
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/hunterlong/statping/core"
|
||||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
|
@ -106,9 +107,16 @@ func (u *mobilePush) OnFailure(s *types.Service, f *types.Failure) {
|
|||
func (u *mobilePush) OnSuccess(s *types.Service) {
|
||||
data := dataJson(s, nil)
|
||||
if !s.Online {
|
||||
var msgStr string
|
||||
if core.CoreApp.UpdateNotify.Bool {
|
||||
msgStr = core.ReturnService(s).SmallText()
|
||||
} else {
|
||||
msgStr = fmt.Sprintf("Your Service %v is Back Online", s.Name)
|
||||
}
|
||||
|
||||
u.ResetUniqueQueue(fmt.Sprintf("service_%v", s.Id))
|
||||
msg := &pushArray{
|
||||
Message: fmt.Sprintf("Your service '%v' is back online!", s.Name),
|
||||
Message: msgStr,
|
||||
Title: "Service Online",
|
||||
Topic: mobileIdentifier,
|
||||
Data: data,
|
||||
|
|
Loading…
Reference in New Issue