Skip to content

Commit

Permalink
fix(ddns): add missing field WebhookRequestType (#436)
Browse files Browse the repository at this point in the history
* fix(ddns): add missing field WebhookRequestType

* add missing placeholders
  • Loading branch information
uubulb authored Oct 17, 2024
1 parent a503f0c commit be7b6e9
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 19 deletions.
2 changes: 2 additions & 0 deletions cmd/dashboard/controller/member_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ type ddnsForm struct {
AccessSecret string
WebhookURL string
WebhookMethod uint8
WebhookRequestType uint8
WebhookRequestBody string
WebhookHeaders string
}
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions model/ddns.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var ProviderList = []DDNSProvider{
AccessSecret: true,
WebhookURL: true,
WebhookMethod: true,
WebhookRequestType: true,
WebhookRequestBody: true,
WebhookHeaders: true,
},
Expand Down Expand Up @@ -93,6 +94,7 @@ type DDNSProvider struct {
AccessSecret bool
WebhookURL bool
WebhookMethod bool
WebhookRequestType bool
WebhookRequestBody bool
WebhookHeaders bool
}
2 changes: 2 additions & 0 deletions pkg/ddns/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "",
)

Expand Down
3 changes: 3 additions & 0 deletions resource/l10n/en-US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@ other = "Webhook URL"
[WebhookMethod]
other = "Webhook Request Method"

[WebhookRequestType]
other = "Webhook Request Type"

[WebhookHeaders]
other = "Webhook Request Headers"

Expand Down
3 changes: 3 additions & 0 deletions resource/l10n/es-ES.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
13 changes: 8 additions & 5 deletions resource/l10n/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "最大重试次数"
Expand All @@ -670,6 +670,9 @@ other = "Webhook 地址"
[WebhookMethod]
other = "Webhook 请求方式"

[WebhookRequestType]
other = "Webhook 请求类型"

[WebhookHeaders]
other = "Webhook 请求头"

Expand Down
29 changes: 16 additions & 13 deletions resource/l10n/zh-TW.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "功能"
Expand Down
6 changes: 5 additions & 1 deletion resource/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions resource/template/component/ddns.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit be7b6e9

Please sign in to comment.