mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 20:58:14 -05:00
fix: 前向兼容性 | for range pointer issue
This commit is contained in:
parent
548d25c9a6
commit
2ccb8f3477
@ -239,7 +239,7 @@ func (ma *memberAPI) addOrEditMonitor(c *gin.Context) {
|
|||||||
err = m.InitSkipServers()
|
err = m.InitSkipServers()
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// 旧版本服务监控可能不存在通知组 为其添加默认的通知组
|
// 保证NotificationTag不为空
|
||||||
if m.NotificationTag == "" {
|
if m.NotificationTag == "" {
|
||||||
m.NotificationTag = "default"
|
m.NotificationTag = "default"
|
||||||
}
|
}
|
||||||
@ -292,6 +292,10 @@ func (ma *memberAPI) addOrEditCron(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
tx := singleton.DB.Begin()
|
tx := singleton.DB.Begin()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
// 保证NotificationTag不为空
|
||||||
|
if cr.NotificationTag == "" {
|
||||||
|
cr.NotificationTag = "default"
|
||||||
|
}
|
||||||
if cf.ID == 0 {
|
if cf.ID == 0 {
|
||||||
err = tx.Create(&cr).Error
|
err = tx.Create(&cr).Error
|
||||||
} else {
|
} else {
|
||||||
@ -483,6 +487,10 @@ func (ma *memberAPI) addOrEditAlertRule(c *gin.Context) {
|
|||||||
enable := arf.Enable == "on"
|
enable := arf.Enable == "on"
|
||||||
r.Enable = &enable
|
r.Enable = &enable
|
||||||
r.ID = arf.ID
|
r.ID = arf.ID
|
||||||
|
//保证NotificationTag不为空
|
||||||
|
if r.NotificationTag == "" {
|
||||||
|
r.NotificationTag = "default"
|
||||||
|
}
|
||||||
if r.ID == 0 {
|
if r.ID == 0 {
|
||||||
err = singleton.DB.Create(&r).Error
|
err = singleton.DB.Create(&r).Error
|
||||||
} else {
|
} else {
|
||||||
@ -567,6 +575,10 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
|
|||||||
singleton.Conf.Site.CustomCode = sf.CustomCode
|
singleton.Conf.Site.CustomCode = sf.CustomCode
|
||||||
singleton.Conf.Site.ViewPassword = sf.ViewPassword
|
singleton.Conf.Site.ViewPassword = sf.ViewPassword
|
||||||
singleton.Conf.Oauth2.Admin = sf.Admin
|
singleton.Conf.Oauth2.Admin = sf.Admin
|
||||||
|
// 保证NotificationTag不为空
|
||||||
|
if singleton.Conf.IPChangeNotificationTag == "" {
|
||||||
|
singleton.Conf.IPChangeNotificationTag = "default"
|
||||||
|
}
|
||||||
if err := singleton.Conf.Save(); err != nil {
|
if err := singleton.Conf.Save(); err != nil {
|
||||||
c.JSON(http.StatusOK, model.Response{
|
c.JSON(http.StatusOK, model.Response{
|
||||||
Code: http.StatusBadRequest,
|
Code: http.StatusBadRequest,
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
value="{{.Conf.IgnoredIPNotification}}">
|
value="{{.Conf.IgnoredIPNotification}}">
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>提醒发送指定的通知分组</label>
|
<label>提醒发送至指定的通知分组</label>
|
||||||
<input type="text" name="IPChangeNotificationTag" placeholder="" value="{{.Conf.IPChangeNotificationTag}}">
|
<input type="text" name="IPChangeNotificationTag" placeholder="" value="{{.Conf.IPChangeNotificationTag}}">
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
@ -149,23 +149,23 @@ func (ss *ServiceSentinel) loadMonitorHistory() {
|
|||||||
var err error
|
var err error
|
||||||
ss.monitorsLock.Lock()
|
ss.monitorsLock.Lock()
|
||||||
defer ss.monitorsLock.Unlock()
|
defer ss.monitorsLock.Unlock()
|
||||||
for _, monitor := range monitors {
|
for i := range monitors {
|
||||||
// 旧版本可能不存在通知组 为其设置默认组
|
// 旧版本可能不存在通知组 为其设置默认组
|
||||||
if monitor.NotificationTag == "" {
|
if monitors[i].NotificationTag == "" {
|
||||||
monitor.NotificationTag = "default"
|
monitors[i].NotificationTag = "default"
|
||||||
DB.Save(monitor)
|
DB.Save(monitors[i])
|
||||||
}
|
}
|
||||||
task := *monitor
|
task := *monitors[i]
|
||||||
// 通过cron定时将服务监控任务传递给任务调度管道
|
// 通过cron定时将服务监控任务传递给任务调度管道
|
||||||
monitor.CronJobID, err = Cron.AddFunc(task.CronSpec(), func() {
|
monitors[i].CronJobID, err = Cron.AddFunc(task.CronSpec(), func() {
|
||||||
ss.dispatchBus <- task
|
ss.dispatchBus <- task
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ss.monitors[monitor.ID] = monitor
|
ss.monitors[monitors[i].ID] = monitors[i]
|
||||||
ss.serviceCurrentStatusData[monitor.ID] = make([]model.MonitorHistory, _CurrentStatusSize)
|
ss.serviceCurrentStatusData[monitors[i].ID] = make([]model.MonitorHistory, _CurrentStatusSize)
|
||||||
ss.serviceStatusToday[monitor.ID] = &_TodayStatsOfMonitor{}
|
ss.serviceStatusToday[monitors[i].ID] = &_TodayStatsOfMonitor{}
|
||||||
}
|
}
|
||||||
|
|
||||||
year, month, day := time.Now().Date()
|
year, month, day := time.Now().Date()
|
||||||
|
Loading…
Reference in New Issue
Block a user