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 AccessSecret string
WebhookURL string WebhookURL string
WebhookMethod uint8 WebhookMethod uint8
WebhookRequestType uint8
WebhookRequestBody string WebhookRequestBody string
WebhookHeaders string WebhookHeaders string
} }
@ -809,6 +810,7 @@ func (ma *memberAPI) addOrEditDDNS(c *gin.Context) {
p.AccessSecret = df.AccessSecret p.AccessSecret = df.AccessSecret
p.WebhookURL = df.WebhookURL p.WebhookURL = df.WebhookURL
p.WebhookMethod = df.WebhookMethod p.WebhookMethod = df.WebhookMethod
p.WebhookRequestType = df.WebhookRequestType
p.WebhookRequestBody = df.WebhookRequestBody p.WebhookRequestBody = df.WebhookRequestBody
p.WebhookHeaders = df.WebhookHeaders p.WebhookHeaders = df.WebhookHeaders

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,6 +48,13 @@
<option value="5">PUT</option> <option value="5">PUT</option>
</select> </select>
</div> </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"> <div class="field">
<label>{{tr "WebhookHeaders"}}</label> <label>{{tr "WebhookHeaders"}}</label>
<textarea name="WebhookHeaders" placeholder='{"User-Agent":"Nezha-Agent"}'></textarea> <textarea name="WebhookHeaders" placeholder='{"User-Agent":"Nezha-Agent"}'></textarea>