mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
add alert api (#458)
This commit is contained in:
@@ -3,6 +3,7 @@ package model
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/naiba/nezha/pkg/utils"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -32,33 +33,25 @@ type DDNSProfile struct {
|
||||
WebhookRequestBody string `json:"webhook_request_body,omitempty"`
|
||||
WebhookHeaders string `json:"webhook_headers,omitempty"`
|
||||
Domains []string `json:"domains,omitempty" gorm:"-"`
|
||||
DomainsRaw string `json:"domains_raw,omitempty"`
|
||||
DomainsRaw string `json:"-"`
|
||||
}
|
||||
|
||||
func (d DDNSProfile) TableName() string {
|
||||
return "ddns"
|
||||
}
|
||||
|
||||
func (d *DDNSProfile) BeforeSave(tx *gorm.DB) error {
|
||||
if data, err := utils.Json.Marshal(d.Domains); err != nil {
|
||||
return err
|
||||
} else {
|
||||
d.DomainsRaw = string(data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DDNSProfile) AfterFind(tx *gorm.DB) error {
|
||||
if d.DomainsRaw != "" {
|
||||
d.Domains = strings.Split(d.DomainsRaw, ",")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DDNSForm struct {
|
||||
ID uint64 `json:"id,omitempty"`
|
||||
MaxRetries uint64 `json:"max_retries,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"`
|
||||
AccessID string `json:"access_id,omitempty"`
|
||||
AccessSecret string `json:"access_secret,omitempty"`
|
||||
WebhookURL string `json:"webhook_url,omitempty"`
|
||||
WebhookMethod uint8 `json:"webhook_method,omitempty"`
|
||||
WebhookRequestType uint8 `json:"webhook_request_type,omitempty"`
|
||||
WebhookRequestBody string `json:"webhook_request_body,omitempty"`
|
||||
WebhookHeaders string `json:"webhook_headers,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user