mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix/notify: Fix the resend mechanism
This commit is contained in:
@@ -378,9 +378,9 @@ func (self *SNotificationManager) fetchUserDetailByClusterID(ctx context.Context
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SNotificationManager) FetchNotOK(lastTime time.Time) ([]SNotification, error) {
|
||||
func (self *SNotificationManager) FetchFailed(lastTime time.Time) ([]SNotification, error) {
|
||||
q := self.Query()
|
||||
q.Filter(sqlchemy.AND(sqlchemy.GE(q.Field("created_at"), lastTime), sqlchemy.NotEquals(q.Field("status"), NOTIFY_OK)))
|
||||
q.Filter(sqlchemy.AND(sqlchemy.GE(q.Field("created_at"), lastTime), sqlchemy.Equals(q.Field("status"), NOTIFY_FAIL)))
|
||||
records := make([]SNotification, 0, 10)
|
||||
err := db.FetchModelObjects(self, q, &records)
|
||||
if err != nil {
|
||||
@@ -489,8 +489,8 @@ func sendWithoutUserCred(notifications []SNotification) {
|
||||
}
|
||||
|
||||
func ReSend(seconds int) {
|
||||
scope := time.Duration(seconds) * time.Second
|
||||
notifications, err := NotificationManager.FetchNotOK(time.Now().Add(-scope))
|
||||
scope := time.Duration(seconds+30) * time.Second
|
||||
notifications, err := NotificationManager.FetchFailed(time.Now().Add(-scope))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user