mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
add setting api (#461)
This commit is contained in:
@@ -54,18 +54,12 @@ func (s *NezhaHandler) ReportTask(c context.Context, r *pb.TaskResult) (*pb.Rece
|
||||
curServer := model.Server{}
|
||||
copier.Copy(&curServer, singleton.ServerList[clientID])
|
||||
if cr.PushSuccessful && r.GetSuccessful() {
|
||||
// singleton.SendNotification(cr.NotificationTag, fmt.Sprintf("[%s] %s, %s\n%s", singleton.Localizer.MustLocalize(
|
||||
// &i18n.LocalizeConfig{
|
||||
// MessageID: "ScheduledTaskExecutedSuccessfully",
|
||||
// },
|
||||
// ), cr.Name, singleton.ServerList[clientID].Name, r.GetData()), nil, &curServer)
|
||||
singleton.SendNotification(cr.NotificationGroupID, fmt.Sprintf("[%s] %s, %s\n%s", "Scheduled Task Executed Successfully",
|
||||
cr.Name, singleton.ServerList[clientID].Name, r.GetData()), nil, &curServer)
|
||||
}
|
||||
if !r.GetSuccessful() {
|
||||
// singleton.SendNotification(cr.NotificationTag, fmt.Sprintf("[%s] %s, %s\n%s", singleton.Localizer.MustLocalize(
|
||||
// &i18n.LocalizeConfig{
|
||||
// MessageID: "ScheduledTaskExecutedFailed",
|
||||
// },
|
||||
// ), cr.Name, singleton.ServerList[clientID].Name, r.GetData()), nil, &curServer)
|
||||
singleton.SendNotification(cr.NotificationGroupID, fmt.Sprintf("[%s] %s, %s\n%s", "Scheduled Task Executed Failed",
|
||||
cr.Name, singleton.ServerList[clientID].Name, r.GetData()), nil, &curServer)
|
||||
}
|
||||
singleton.DB.Model(cr).Updates(model.Cron{
|
||||
LastExecutedAt: time.Now().Add(time.Second * -1 * time.Duration(r.GetDelay())),
|
||||
@@ -156,16 +150,14 @@ func (s *NezhaHandler) ReportSystemInfo(c context.Context, r *pb.Host) (*pb.Rece
|
||||
host.IP != "" &&
|
||||
singleton.ServerList[clientID].Host.IP != host.IP {
|
||||
|
||||
// singleton.SendNotification(singleton.Conf.IPChangeNotificationTag,
|
||||
// fmt.Sprintf(
|
||||
// "[%s] %s, %s => %s",
|
||||
// singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
// MessageID: "IPChanged",
|
||||
// }),
|
||||
// singleton.ServerList[clientID].Name, singleton.IPDesensitize(singleton.ServerList[clientID].Host.IP),
|
||||
// singleton.IPDesensitize(host.IP),
|
||||
// ),
|
||||
// nil)
|
||||
singleton.SendNotification(singleton.Conf.IPChangeNotificationGroupID,
|
||||
fmt.Sprintf(
|
||||
"[%s] %s, %s => %s",
|
||||
"IPChanged",
|
||||
singleton.ServerList[clientID].Name, singleton.IPDesensitize(singleton.ServerList[clientID].Host.IP),
|
||||
singleton.IPDesensitize(host.IP),
|
||||
),
|
||||
nil)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -602,14 +602,17 @@ func StatusCodeToString(statusCode int) string {
|
||||
switch statusCode {
|
||||
case StatusNoData:
|
||||
// return Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "StatusNoData"})
|
||||
return "No Data"
|
||||
case StatusGood:
|
||||
// return Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "StatusGood"})
|
||||
return "Good"
|
||||
case StatusLowAvailability:
|
||||
// return Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "StatusLowAvailability"})
|
||||
return "Low Availability"
|
||||
case StatusDown:
|
||||
// return Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "StatusDown"})
|
||||
return "Down"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user