[REFACTOR] webhook dingtalk endpoint
This commit is contained in:
parent
c3f8e6ed60
commit
9dff719523
4 changed files with 15 additions and 36 deletions
|
@ -292,18 +292,6 @@ func (f *NewGogshookForm) Validate(req *http.Request, errs binding.Errors) bindi
|
|||
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
||||
}
|
||||
|
||||
// NewDingtalkHookForm form for creating dingtalk hook
|
||||
type NewDingtalkHookForm struct {
|
||||
PayloadURL string `binding:"Required;ValidUrl"`
|
||||
WebhookForm
|
||||
}
|
||||
|
||||
// Validate validates the fields
|
||||
func (f *NewDingtalkHookForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
|
||||
ctx := context.GetValidateContext(req)
|
||||
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
||||
}
|
||||
|
||||
// NewTelegramHookForm form for creating telegram hook
|
||||
type NewTelegramHookForm struct {
|
||||
BotToken string `binding:"Required"`
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
webhook_module "code.gitea.io/gitea/modules/webhook"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
|
||||
dingtalk "gitea.com/lunny/dingtalk_webhook"
|
||||
)
|
||||
|
@ -24,7 +25,20 @@ type dingtalkHandler struct{}
|
|||
func (dingtalkHandler) Type() webhook_module.HookType { return webhook_module.DINGTALK }
|
||||
func (dingtalkHandler) Metadata(*webhook_model.Webhook) any { return nil }
|
||||
func (dingtalkHandler) FormFields(bind func(any)) FormFields {
|
||||
panic("TODO")
|
||||
var form struct {
|
||||
forms.WebhookForm
|
||||
PayloadURL string `binding:"Required;ValidUrl"`
|
||||
}
|
||||
bind(&form)
|
||||
|
||||
return FormFields{
|
||||
WebhookForm: form.WebhookForm,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: webhook_model.ContentTypeJSON,
|
||||
Secret: "",
|
||||
HTTPMethod: http.MethodPost,
|
||||
Metadata: nil,
|
||||
}
|
||||
}
|
||||
|
||||
type (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue