diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 6823d8e..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index e515e0a..a307657 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,15 @@ +## IDE .idea +.vscode + +## golang vendor logs go.sum -manifest -cmd/.DS_Store -cmd/hummingbird-ui/.DS_Store -hummingbird -mqtt-broker \ No newline at end of file + +## MacOS +.DS_Store + +## binary +cmd/hummingbird-core/hummingbird-core +cmd/mqtt-broker/mqtt-broker \ No newline at end of file diff --git a/go.mod b/go.mod index 8507510..5181408 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.18 require ( github.com/BurntSushi/toml v1.1.0 - github.com/alexmullins/zip v0.0.0-20180717182244-4affb64b04d0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/docker/distribution v2.8.1+incompatible github.com/docker/docker v20.10.17+incompatible diff --git a/internal/hummingbird/core/application/alertcentreapp/alertapp.go b/internal/hummingbird/core/application/alertcentreapp/alertapp.go index 7ad46e0..75bc303 100644 --- a/internal/hummingbird/core/application/alertcentreapp/alertapp.go +++ b/internal/hummingbird/core/application/alertcentreapp/alertapp.go @@ -800,36 +800,25 @@ func (p alertApp) AddAlert(ctx context.Context, req map[string]interface{}) erro } } + if alertRule.SilenceTime > 0 { + alertSend, err := p.dbClient.AlertListLastSend(alertRule.Id) + if err != nil { + if !errors.Is(err, gorm.ErrRecordNotFound) { + // 处理不是记录未找到的情况 + return err + } + } else { + if alertSend.Created+alertRule.SilenceTime > utils.MakeTimestamp() { + // 在静默期内,不发送 + return nil + } + } + } + var alertList models.AlertList alertList.AlertRuleId = alertRule.Id alertList.AlertResult = alertResult alertList.TriggerTime = time.Now().UnixMilli() - - send := false - if alertRule.SilenceTime > 0 { - alertSend, err := p.dbClient.AlertListLastSend(alertRule.Id) - if err != nil { - if err == gorm.ErrRecordNotFound { - send = true - goto Jump - } - } else { - if alertSend.Created+alertRule.SilenceTime <= utils.MakeTimestamp() { - send = true - goto Jump - } - } - } - -Jump: - if send == false { - alertList.IsSend = false - _, err = p.dbClient.AddAlertList(alertList) - if err != nil { - return err - } - return nil - } alertList.IsSend = true alertList.Status = constants.Untreated diff --git a/internal/pkg/packets/.DS_Store b/internal/pkg/packets/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/internal/pkg/packets/.DS_Store and /dev/null differ