From be7b6e9c5ecdae24d964376a97c67fc2f1e6a6cc Mon Sep 17 00:00:00 2001 From: UUBulb <35923940+uubulb@users.noreply.github.com> Date: Thu, 17 Oct 2024 23:35:28 +0800 Subject: [PATCH] fix(ddns): add missing field WebhookRequestType (#436) * fix(ddns): add missing field WebhookRequestType * add missing placeholders --- cmd/dashboard/controller/member_api.go | 2 ++ model/ddns.go | 2 ++ pkg/ddns/webhook/webhook.go | 2 ++ resource/l10n/en-US.toml | 3 +++ resource/l10n/es-ES.toml | 3 +++ resource/l10n/zh-CN.toml | 13 +++++++----- resource/l10n/zh-TW.toml | 29 ++++++++++++++------------ resource/static/main.js | 6 +++++- resource/template/component/ddns.html | 7 +++++++ 9 files changed, 48 insertions(+), 19 deletions(-) diff --git a/cmd/dashboard/controller/member_api.go b/cmd/dashboard/controller/member_api.go index 1b3faa4..e038f57 100644 --- a/cmd/dashboard/controller/member_api.go +++ b/cmd/dashboard/controller/member_api.go @@ -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 diff --git a/model/ddns.go b/model/ddns.go index 3a19b64..3451110 100644 --- a/model/ddns.go +++ b/model/ddns.go @@ -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 } diff --git a/pkg/ddns/webhook/webhook.go b/pkg/ddns/webhook/webhook.go index fde7199..90e7bfa 100644 --- a/pkg/ddns/webhook/webhook.go +++ b/pkg/ddns/webhook/webhook.go @@ -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", "", ) diff --git a/resource/l10n/en-US.toml b/resource/l10n/en-US.toml index c96fd94..cfdf7ed 100644 --- a/resource/l10n/en-US.toml +++ b/resource/l10n/en-US.toml @@ -670,6 +670,9 @@ other = "Webhook URL" [WebhookMethod] other = "Webhook Request Method" +[WebhookRequestType] +other = "Webhook Request Type" + [WebhookHeaders] other = "Webhook Request Headers" diff --git a/resource/l10n/es-ES.toml b/resource/l10n/es-ES.toml index d412fed..c008fc4 100644 --- a/resource/l10n/es-ES.toml +++ b/resource/l10n/es-ES.toml @@ -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" diff --git a/resource/l10n/zh-CN.toml b/resource/l10n/zh-CN.toml index a01e099..d990355 100644 --- a/resource/l10n/zh-CN.toml +++ b/resource/l10n/zh-CN.toml @@ -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 请求头" diff --git a/resource/l10n/zh-TW.toml b/resource/l10n/zh-TW.toml index f4ab873..227eba5 100644 --- a/resource/l10n/zh-TW.toml +++ b/resource/l10n/zh-TW.toml @@ -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 = "功能" diff --git a/resource/static/main.js b/resource/static/main.js index da7c59a..3747ff3 100644 --- a/resource/static/main.js +++ b/resource/static/main.js @@ -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 { diff --git a/resource/template/component/ddns.html b/resource/template/component/ddns.html index 55215e4..951d49a 100644 --- a/resource/template/component/ddns.html +++ b/resource/template/component/ddns.html @@ -48,6 +48,13 @@ +