Add support for disabling repeat notifications

* Add a new database function for getting the tail

* Update ShouldNotify() to handle ignoring repeat notifications if set
This commit is contained in:
Aram Akhavan
2023-11-26 22:43:50 -08:00
parent 6417d71311
commit 4e5c76b259
4 changed files with 139 additions and 36 deletions
@@ -2,6 +2,8 @@ package handler
import (
"fmt"
"net/http"
"github.com/analogj/scrutiny/webapp/backend/pkg"
"github.com/analogj/scrutiny/webapp/backend/pkg/config"
"github.com/analogj/scrutiny/webapp/backend/pkg/database"
@@ -9,7 +11,6 @@ import (
"github.com/analogj/scrutiny/webapp/backend/pkg/notify"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"net/http"
)
func UploadDeviceMetrics(c *gin.Context) {
@@ -73,6 +74,9 @@ func UploadDeviceMetrics(c *gin.Context) {
smartData,
pkg.MetricsStatusThreshold(appConfig.GetInt(fmt.Sprintf("%s.metrics.status_threshold", config.DB_USER_SETTINGS_SUBKEY))),
pkg.MetricsStatusFilterAttributes(appConfig.GetInt(fmt.Sprintf("%s.metrics.status_filter_attributes", config.DB_USER_SETTINGS_SUBKEY))),
appConfig.GetBool(fmt.Sprintf("%s.metrics.repeat_notifications", config.DB_USER_SETTINGS_SUBKEY)),
c,
deviceRepo,
) {
//send notifications