fix(ddns): add missing field WebhookRequestType (#436)

* fix(ddns): add missing field WebhookRequestType

* add missing placeholders
This commit is contained in:
UUBulb 2024-10-17 23:35:28 +08:00 committed by GitHub
parent a503f0cf40
commit be7b6e9c5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 48 additions and 19 deletions

View File

@ -781,6 +781,7 @@ type ddnsForm struct {
AccessSecret string
WebhookURL string
WebhookMethod uint8
WebhookRequestType uint8
WebhookRequestBody string
WebhookHeaders string
}
@ -809,6 +810,7 @@ func (ma *memberAPI) addOrEditDDNS(c *gin.Context) {
p.AccessSecret = df.AccessSecret
p.WebhookURL = df.WebhookURL
p.WebhookMethod = df.WebhookMethod
p.WebhookRequestType = df.WebhookRequestType
p.WebhookRequestBody = df.WebhookRequestBody
p.WebhookHeaders = df.WebhookHeaders

View File

@ -51,6 +51,7 @@ var ProviderList = []DDNSProvider{
AccessSecret: true,
WebhookURL: true,
WebhookMethod: true,
WebhookRequestType: true,
WebhookRequestBody: true,
WebhookHeaders: true,
},
@ -93,6 +94,7 @@ type DDNSProvider struct {
AccessSecret bool
WebhookURL bool
WebhookMethod bool
WebhookRequestType bool
WebhookRequestBody bool
WebhookHeaders bool
}

View File

@ -159,6 +159,8 @@ func (provider *Provider) formatWebhookString(s string) string {
"#domain#", provider.domain,
"#type#", provider.ipType,
"#record#", provider.recordType,
"#access_id#", provider.DDNSProfile.AccessID,
"#access_secret#", provider.DDNSProfile.AccessSecret,
"\r", "",
)

View File

@ -670,6 +670,9 @@ other = "Webhook URL"
[WebhookMethod]
other = "Webhook Request Method"
[WebhookRequestType]
other = "Webhook Request Type"
[WebhookHeaders]
other = "Webhook Request Headers"

View File

@ -670,6 +670,9 @@ other = "URL del Webhook"
[WebhookMethod]
other = "Método de Solicitud del Webhook"
[WebhookRequestType]
other = "Tipo de solicitud del Webhook"
[WebhookHeaders]
other = "Encabezados de Solicitud del Webhook"

View File

@ -632,22 +632,22 @@ other = "DDNS配置"
other = "新配置"
[EnableDDNS]
other = "启用DDNS"
other = "启用 DDNS"
[EnableIPv4]
other = "启用DDNS IPv4"
other = "启用 DDNS IPv4"
[EnableIPv6]
other = "启用DDNS IPv6"
other = "启用 DDNS IPv6"
[DDNSDomain]
other = "DDNS域名"
other = "DDNS 域名"
[DDNSDomains]
other = "域名(逗号分隔)"
[DDNSProvider]
other = "DDNS供应商"
other = "DDNS 供应商"
[MaxRetries]
other = "最大重试次数"
@ -670,6 +670,9 @@ other = "Webhook 地址"
[WebhookMethod]
other = "Webhook 请求方式"
[WebhookRequestType]
other = "Webhook 请求类型"
[WebhookHeaders]
other = "Webhook 请求头"

View File

@ -632,49 +632,52 @@ other = "DDNS配置"
other = "新增配置"
[EnableDDNS]
other = "啟用DDNS"
other = "啟用 DDNS"
[EnableIPv4]
other = "啟用DDNS IPv4"
other = "啟用 DDNS IPv4"
[EnableIPv6]
other = "啟用DDNS IPv6"
other = "啟用 DDNS IPv6"
[DDNSDomain]
other = "DDNS域名"
other = "DDNS 域名"
[DDNSDomains]
other = "域名(逗號分隔)"
[DDNSProvider]
other = "DDNS供應商"
other = "DDN S供應商"
[MaxRetries]
other = "最大重試次數"
[DDNSAccessID]
other = "DDNS憑據1"
other = "DDNS 憑據 1"
[DDNSAccessSecret]
other = "DDNS憑據2"
other = "DDNS 憑據 2"
[DDNSTokenID]
other = "令牌ID"
other = "令牌 ID"
[DDNSTokenSecret]
other = "令牌Secret"
other = "令牌 Secret"
[WebhookURL]
other = "Webhook地址"
other = "Webhook 地址"
[WebhookMethod]
other = "Webhook請求方式"
other = "Webhook 請求方式"
[WebhookRequestType]
other = "Webhook 請求類型"
[WebhookHeaders]
other = "Webhook請求頭"
other = "Webhook 請求頭"
[WebhookRequestBody]
other = "Webhook請求體"
other = "Webhook 請求體"
[Feature]
other = "功能"

View File

@ -102,7 +102,8 @@ function showFormModal(modelSelector, formID, URL, getData) {
item.name === "Duration" ||
item.name === "MaxRetries" ||
item.name === "Provider" ||
item.name === "WebhookMethod"
item.name === "WebhookMethod" ||
item.name === "WebhookRequestType"
) {
obj[item.name] = parseInt(item.value);
} else if (item.name.endsWith("Latency")) {
@ -299,6 +300,9 @@ function addOrEditDDNS(ddns) {
modal
.find("select[name=WebhookMethod]")
.val(ddns ? ddns.WebhookMethod : 1);
modal
.find("select[name=WebhookRequestType]")
.val(ddns ? ddns.WebhookRequestType : 1);
if (ddns && ddns.EnableIPv4) {
modal.find(".ui.enableipv4.checkbox").checkbox("set checked");
} else {

View File

@ -48,6 +48,13 @@
<option value="5">PUT</option>
</select>
</div>
<div class="field">
<label>{{tr "WebhookRequestType"}}</label>
<select name="WebhookRequestType" class="ui fluid dropdown">
<option value="1">JSON</option>
<option value="2">Form</option>
</select>
</div>
<div class="field">
<label>{{tr "WebhookHeaders"}}</label>
<textarea name="WebhookHeaders" placeholder='{"User-Agent":"Nezha-Agent"}'></textarea>