fixing notifications.
This commit is contained in:
@@ -35,6 +35,8 @@ func (c *configuration) Init() error {
|
|||||||
c.SetDefault("log.level", "INFO")
|
c.SetDefault("log.level", "INFO")
|
||||||
c.SetDefault("log.file", "")
|
c.SetDefault("log.file", "")
|
||||||
|
|
||||||
|
c.SetDefault("notify.urls", []string{})
|
||||||
|
|
||||||
//c.SetDefault("disks.include", []string{})
|
//c.SetDefault("disks.include", []string{})
|
||||||
//c.SetDefault("disks.exclude", []string{})
|
//c.SetDefault("disks.exclude", []string{})
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Create mock using:
|
// Create mock using:
|
||||||
// mockgen -source=pkg/config/interface.go -destination=pkg/config/mock/mock_config.go
|
// mockgen -source=webapp/backend/pkg/config/interface.go -destination=webapp/backend/pkg/config/mock/mock_config.go
|
||||||
type Interface interface {
|
type Interface interface {
|
||||||
Init() error
|
Init() error
|
||||||
ReadConfig(configFilePath string) error
|
ReadConfig(configFilePath string) error
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ func (n *Notify) Send() error {
|
|||||||
configUrls := n.Config.GetStringSlice("notify.urls")
|
configUrls := n.Config.GetStringSlice("notify.urls")
|
||||||
n.Logger.Debugf("Configured notification services: %v", configUrls)
|
n.Logger.Debugf("Configured notification services: %v", configUrls)
|
||||||
|
|
||||||
|
if len(configUrls) == 0 {
|
||||||
|
n.Logger.Infof("No notification endpoints configured. Skipping failure notification.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
//remove http:// https:// and script:// prefixed urls
|
//remove http:// https:// and script:// prefixed urls
|
||||||
notifyWebhooks := []string{}
|
notifyWebhooks := []string{}
|
||||||
notifyScripts := []string{}
|
notifyScripts := []string{}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ func UploadDeviceMetrics(c *gin.Context) {
|
|||||||
DeviceSerial: device.SerialNumber,
|
DeviceSerial: device.SerialNumber,
|
||||||
Test: false,
|
Test: false,
|
||||||
},
|
},
|
||||||
|
Logger: logger,
|
||||||
}
|
}
|
||||||
_ = testNotify.Send() //we ignore error message when sending notifications.
|
_ = testNotify.Send() //we ignore error message when sending notifications.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ func TestPopulateMultiple(t *testing.T) {
|
|||||||
defer mockCtrl.Finish()
|
defer mockCtrl.Finish()
|
||||||
fakeConfig := mock_config.NewMockInterface(mockCtrl)
|
fakeConfig := mock_config.NewMockInterface(mockCtrl)
|
||||||
//fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return("testdata/scrutiny_test.db")
|
//fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return("testdata/scrutiny_test.db")
|
||||||
|
fakeConfig.EXPECT().GetStringSlice("notify.urls").Return([]string{}).AnyTimes()
|
||||||
fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return(path.Join(parentPath, "scrutiny_test.db"))
|
fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return(path.Join(parentPath, "scrutiny_test.db"))
|
||||||
fakeConfig.EXPECT().GetString("web.src.frontend.path").AnyTimes().Return(parentPath)
|
fakeConfig.EXPECT().GetString("web.src.frontend.path").AnyTimes().Return(parentPath)
|
||||||
ae := web.AppEngine{
|
ae := web.AppEngine{
|
||||||
|
|||||||
Reference in New Issue
Block a user