diff --git a/object/webhook.go b/object/webhook.go index e64bd7a2..11d3d93f 100644 --- a/object/webhook.go +++ b/object/webhook.go @@ -27,6 +27,7 @@ type Webhook struct { CreatedTime string `xorm:"varchar(100)" json:"createdTime"` Url string `xorm:"varchar(100)" json:"url"` + Method string `xorm:"varchar(100)" json:"method"` ContentType string `xorm:"varchar(100)" json:"contentType"` Events []string `xorm:"varchar(100)" json:"events"` diff --git a/object/webhook_util.go b/object/webhook_util.go index 942703ad..a8af279f 100644 --- a/object/webhook_util.go +++ b/object/webhook_util.go @@ -26,7 +26,7 @@ func sendWebhook(webhook *Webhook, record *Record) error { body := strings.NewReader(util.StructToJson(record)) - req, err := http.NewRequest("POST", webhook.Url, body) + req, err := http.NewRequest(webhook.Method, webhook.Url, body) if err != nil { return err } diff --git a/web/src/WebhookEditPage.js b/web/src/WebhookEditPage.js index 15e5a334..75bbe5e2 100644 --- a/web/src/WebhookEditPage.js +++ b/web/src/WebhookEditPage.js @@ -114,6 +114,23 @@ class WebhookEditPage extends React.Component { }} /> + + + {Setting.getLabel(i18next.t("webhook:Method"), i18next.t("webhook:Method - Tooltip"))} : + + + + + {Setting.getLabel(i18next.t("webhook:Content type"), i18next.t("webhook:Content type - Tooltip"))} : diff --git a/web/src/WebhookListPage.js b/web/src/WebhookListPage.js index 0cb40347..516bce92 100644 --- a/web/src/WebhookListPage.js +++ b/web/src/WebhookListPage.js @@ -20,10 +20,8 @@ import * as Setting from "./Setting"; import * as WebhookBackend from "./backend/WebhookBackend"; import i18next from "i18next"; import BaseListPage from "./BaseListPage"; -import * as ProviderBackend from "./backend/ProviderBackend"; class WebhookListPage extends BaseListPage { - newWebhook() { const randomName = Setting.getRandomName(); return { @@ -31,6 +29,7 @@ class WebhookListPage extends BaseListPage { name: `webhook_${randomName}`, createdTime: moment().format(), url: "https://example.com/callback", + method: "POST", contentType: "application/json", events: ["signup", "login", "logout", "update-user"], organization: "built-in", @@ -125,11 +124,19 @@ class WebhookListPage extends BaseListPage { ) } }, + { + title: i18next.t("webhook:Method"), + dataIndex: 'method', + key: 'method', + width: '120px', + sorter: true, + ...this.getColumnSearchProps('method'), + }, { title: i18next.t("webhook:Content type"), dataIndex: 'contentType', key: 'contentType', - width: '150px', + width: '200px', sorter: true, filterMultiple: false, filters: [