mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-05 05:00:05 +00:00
implement notification group (#450)
* implement notification group * some fixes * fix sql * add listNotification * retrieve notification from map * create notification_group_notification if non-exist * NotificationIDToGroup -> NotificationIDToGroups * clean
This commit is contained in:
@@ -29,7 +29,7 @@ type AlertRule struct {
|
||||
RulesRaw string
|
||||
Enable *bool
|
||||
TriggerMode int `gorm:"default:0"` // 触发模式: 0-始终触发(默认) 1-单次触发
|
||||
NotificationTag string // 该报警规则所在的通知组
|
||||
NotificationGroupID uint64 // 该报警规则所在的通知组
|
||||
FailTriggerTasksRaw string `gorm:"default:'[]'"`
|
||||
RecoverTriggerTasksRaw string `gorm:"default:'[]'"`
|
||||
Rules []Rule `gorm:"-" json:"-"`
|
||||
|
||||
@@ -18,16 +18,16 @@ const (
|
||||
|
||||
type Cron struct {
|
||||
Common
|
||||
Name string
|
||||
TaskType uint8 `gorm:"default:0"` // 0:计划任务 1:触发任务
|
||||
Scheduler string //分钟 小时 天 月 星期
|
||||
Command string
|
||||
Servers []uint64 `gorm:"-"`
|
||||
PushSuccessful bool // 推送成功的通知
|
||||
NotificationTag string // 指定通知方式的分组
|
||||
LastExecutedAt time.Time // 最后一次执行时间
|
||||
LastResult bool // 最后一次执行结果
|
||||
Cover uint8 // 计划任务覆盖范围 (0:仅覆盖特定服务器 1:仅忽略特定服务器 2:由触发该计划任务的服务器执行)
|
||||
Name string
|
||||
TaskType uint8 `gorm:"default:0"` // 0:计划任务 1:触发任务
|
||||
Scheduler string //分钟 小时 天 月 星期
|
||||
Command string
|
||||
Servers []uint64 `gorm:"-"`
|
||||
PushSuccessful bool // 推送成功的通知
|
||||
NotificationGroupID uint64 // 指定通知方式的分组
|
||||
LastExecutedAt time.Time // 最后一次执行时间
|
||||
LastResult bool // 最后一次执行结果
|
||||
Cover uint8 // 计划任务覆盖范围 (0:仅覆盖特定服务器 1:仅忽略特定服务器 2:由触发该计划任务的服务器执行)
|
||||
|
||||
CronJobID cron.EntryID `gorm:"-"`
|
||||
ServersRaw string
|
||||
|
||||
@@ -49,8 +49,8 @@ func (d *DDNSProfile) AfterFind(tx *gorm.DB) error {
|
||||
type DDNSForm struct {
|
||||
ID uint64 `json:"id,omitempty"`
|
||||
MaxRetries uint64 `json:"max_retries,omitempty"`
|
||||
EnableIPv4 string `json:"enable_ipv4,omitempty"`
|
||||
EnableIPv6 string `json:"enable_ipv6,omitempty"`
|
||||
EnableIPv4 bool `json:"enable_ipv4,omitempty"`
|
||||
EnableIPv6 bool `json:"enable_ipv6,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Provider string `json:"provider,omitempty"`
|
||||
DomainsRaw string `json:"domains_raw,omitempty"`
|
||||
|
||||
@@ -46,14 +46,14 @@ const (
|
||||
|
||||
type Monitor struct {
|
||||
Common
|
||||
Name string
|
||||
Type uint8
|
||||
Target string
|
||||
SkipServersRaw string
|
||||
Duration uint64
|
||||
Notify bool
|
||||
NotificationTag string // 当前服务监控所属的通知组
|
||||
Cover uint8
|
||||
Name string
|
||||
Type uint8
|
||||
Target string
|
||||
SkipServersRaw string
|
||||
Duration uint64
|
||||
Notify bool
|
||||
NotificationGroupID uint64 // 当前服务监控所属的通知组 ID
|
||||
Cover uint8
|
||||
|
||||
EnableTriggerTask bool `gorm:"default: false"`
|
||||
EnableShowInService bool `gorm:"default: false"`
|
||||
|
||||
@@ -32,14 +32,25 @@ type NotificationServerBundle struct {
|
||||
|
||||
type Notification struct {
|
||||
Common
|
||||
Name string
|
||||
Tag string // 分组名
|
||||
URL string
|
||||
RequestMethod int
|
||||
RequestType int
|
||||
RequestHeader string `gorm:"type:longtext" `
|
||||
RequestBody string `gorm:"type:longtext" `
|
||||
VerifySSL *bool
|
||||
Name string `json:"name,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
RequestMethod int `json:"request_method,omitempty"`
|
||||
RequestType int `json:"request_type,omitempty"`
|
||||
RequestHeader string `json:"request_header,omitempty" gorm:"type:longtext"`
|
||||
RequestBody string `json:"request_body,omitempty" gorm:"type:longtext"`
|
||||
VerifySSL *bool `json:"verify_ssl,omitempty"`
|
||||
}
|
||||
|
||||
type NotificationForm struct {
|
||||
ID uint64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
RequestMethod int `json:"request_method,omitempty"`
|
||||
RequestType int `json:"request_type,omitempty"`
|
||||
RequestHeader string `json:"request_header,omitempty"`
|
||||
RequestBody string `json:"request_body,omitempty"`
|
||||
VerifySSL bool `json:"verify_ssl,omitempty"`
|
||||
SkipCheck bool `json:"skip_check,omitempty"`
|
||||
}
|
||||
|
||||
func (ns *NotificationServerBundle) reqURL(message string) string {
|
||||
|
||||
11
model/notification_group_api.go
Normal file
11
model/notification_group_api.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
type NotificationGroupForm struct {
|
||||
Name string `json:"name"`
|
||||
Notifications []uint64 `json:"notifications"`
|
||||
}
|
||||
|
||||
type NotificationGroupResponseItem struct {
|
||||
Group NotificationGroup `json:"group"`
|
||||
Notifications []uint64 `json:"notifications"`
|
||||
}
|
||||
@@ -2,6 +2,6 @@ package model
|
||||
|
||||
type NotificationGroupNotification struct {
|
||||
Common
|
||||
NotificationGroupID uint64 `json:"notification_group_id"`
|
||||
NotificationID uint64 `json:"notification_id"`
|
||||
NotificationGroupID uint64 `json:"notification_group_id" gorm:"uniqueIndex:idx_notification_group_notification"`
|
||||
NotificationID uint64 `json:"notification_id" gorm:"uniqueIndex:idx_notification_group_notification"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user