diff --git a/.gitignore b/.gitignore index d0b07313..ccdb9205 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ snap prime stage parts +assets_backup certs releases core/rice-box.go diff --git a/frontend/src/API.js b/frontend/src/API.js index 49ef994c..82dbb00b 100644 --- a/frontend/src/API.js +++ b/frontend/src/API.js @@ -7,8 +7,8 @@ const tokenKey = "statping_auth"; class Api { constructor() { - this.version = "0.90.64"; - this.commit = "130cc3ede7463ec9af8d62abb84992e2a0ef453c"; + this.version = "0.90.65"; + this.commit = "3051206a7a843b97c92462a536f1c54ee92fbab8"; } async oauth() { diff --git a/frontend/src/pages/Help.vue b/frontend/src/pages/Help.vue index 9c79c834..62fae234 100755 --- a/frontend/src/pages/Help.vue +++ b/frontend/src/pages/Help.vue @@ -2275,7 +2275,7 @@ OluFxewsEO0QNDrfFb+0gnjYlnGqOFcZjUMXbDdY5oLSPtXohynuTK1qyQ==
-Automatically generated from Statping's Wiki on 2020-08-22 21:27:09.3468 +0000 UTC +Automatically generated from Statping's Wiki on 2020-08-30 00:32:40.685063 +0000 UTC
diff --git a/handlers/notifications.go b/handlers/notifications.go index c542a0db..da4a2c1f 100644 --- a/handlers/notifications.go +++ b/handlers/notifications.go @@ -13,17 +13,7 @@ import ( func apiNotifiersHandler(w http.ResponseWriter, r *http.Request) { var notifs []notifications.Notification for _, n := range services.AllNotifiers() { - log.Warningln(n) - no := n.Select() - log.Warningln(no.Method) - notif, err := notifications.Find(no.Method) - if err != nil { - log.Errorln(err) - sendErrorJson(err, w, r) - return - } - updated := no.UpdateFields(notif) - notifs = append(notifs, *updated) + notifs = append(notifs, *n.Select()) } sort.Sort(notifications.NotificationOrder(notifs)) returnJson(notifs, w, r) diff --git a/handlers/routes.go b/handlers/routes.go index 8254101f..576431ae 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -68,12 +68,8 @@ func Router() *mux.Router { } if source.UsingAssets(dir) { - indexHandler := http.FileServer(http.Dir(dir + "/assets/")) - - r.PathPrefix("/css/").Handler(http.StripPrefix(basePath, staticAssets("css"))) - r.PathPrefix("/favicon/").Handler(http.StripPrefix(basePath, staticAssets("favicon"))) - r.PathPrefix("/robots.txt").Handler(http.StripPrefix(basePath, indexHandler)) - r.PathPrefix("/banner.png").Handler(http.StripPrefix(basePath, indexHandler)) + prefixed := http.StripPrefix(basePath+"assets/", http.FileServer(http.Dir(dir+"/assets/"))) + r.PathPrefix("/assets/").Handler(prefixed) } else { tmplFileSrv := http.FileServer(source.TmplBox.HTTPBox()) tmplBoxHandler := http.StripPrefix(basePath, tmplFileSrv) diff --git a/notifiers/notifiers.go b/notifiers/notifiers.go index 78b82e93..ec23bd1e 100644 --- a/notifiers/notifiers.go +++ b/notifiers/notifiers.go @@ -37,6 +37,8 @@ func InitNotifiers() { Gotify, AmazonSNS, ) + + services.UpdateNotifiers() } func ReplaceTemplate(tmpl string, data replacer) string { diff --git a/notifiers/slack.go b/notifiers/slack.go index 8566c6dd..f476da66 100644 --- a/notifiers/slack.go +++ b/notifiers/slack.go @@ -9,7 +9,6 @@ import ( "github.com/statping/statping/types/null" "github.com/statping/statping/types/services" "github.com/statping/statping/utils" - "regexp" "strings" "time" ) @@ -94,10 +93,5 @@ func (s *slack) OnSave() (string, error) { } func (s *slack) Valid(values notifications.Values) error { - regex := `https\:\/\/hooks\.slack\.com/services/[A-Z0-9]{7,11}/[A-Z0-9]{7,11}/[a-zA-Z0-9]{20,22}` - r := regexp.MustCompile(regex) - if !r.MatchString(values.Host) { - return errors.New("slack webhook does not match with expected regex " + regex) - } return nil } diff --git a/types/notifications/database.go b/types/notifications/database.go index d4b1f40d..37c5779a 100644 --- a/types/notifications/database.go +++ b/types/notifications/database.go @@ -25,6 +25,15 @@ func (n *Notification) Values() Values { } } +func All() []*Notification { + var n []*Notification + q := db.Find(&n) + if q.Error() != nil { + return nil + } + return n +} + func Find(method string) (*Notification, error) { var n Notification q := db.Where("method = ?", method).Find(&n) diff --git a/types/null/marshal.go b/types/null/marshal.go index 8cbc5671..ac23d436 100644 --- a/types/null/marshal.go +++ b/types/null/marshal.go @@ -6,13 +6,6 @@ import ( "gopkg.in/yaml.v2" ) -func (s NullString) Scan(value interface{}) error { - if s.Valid { - s.String = value.(string) - } - return nil -} - func (s NullString) Value() (driver.Value, error) { return s.String, nil } diff --git a/types/services/notifications.go b/types/services/notifications.go index 80b58182..352df55e 100644 --- a/types/services/notifications.go +++ b/types/services/notifications.go @@ -11,6 +11,13 @@ func AddNotifier(n ServiceNotifier) { allNotifiers[notif.Method] = n } +func UpdateNotifiers() { + for _, n := range notifications.All() { + notifier := allNotifiers[n.Method] + notifier.Select().UpdateFields(n) + } +} + func sendSuccess(s *Service) { if !s.AllowNotifications.Bool { return