[REFACTOR] webhook slack endpoints
This commit is contained in:
parent
7e0965b02c
commit
6f00821f3d
4 changed files with 44 additions and 54 deletions
|
@ -481,33 +481,6 @@ func mSTeamsHookParams(ctx *context.Context) webhookParams {
|
|||
}
|
||||
}
|
||||
|
||||
// SlackHooksNewPost response for creating Slack webhook
|
||||
func SlackHooksNewPost(ctx *context.Context) {
|
||||
createWebhook(ctx, slackHookParams(ctx))
|
||||
}
|
||||
|
||||
// SlackHooksEditPost response for editing Slack webhook
|
||||
func SlackHooksEditPost(ctx *context.Context) {
|
||||
editWebhook(ctx, slackHookParams(ctx))
|
||||
}
|
||||
|
||||
func slackHookParams(ctx *context.Context) webhookParams {
|
||||
form := web.GetForm(ctx).(*forms.NewSlackHookForm)
|
||||
|
||||
return webhookParams{
|
||||
Type: webhook_module.SLACK,
|
||||
URL: form.PayloadURL,
|
||||
ContentType: webhook.ContentTypeJSON,
|
||||
WebhookForm: form.WebhookForm,
|
||||
Meta: &webhook_service.SlackMeta{
|
||||
Channel: strings.TrimSpace(form.Channel),
|
||||
Username: form.Username,
|
||||
IconURL: form.IconURL,
|
||||
Color: form.Color,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// FeishuHooksNewPost response for creating Feishu webhook
|
||||
func FeishuHooksNewPost(ctx *context.Context) {
|
||||
createWebhook(ctx, feishuHookParams(ctx))
|
||||
|
|
|
@ -403,7 +403,6 @@ func registerRoutes(m *web.Route) {
|
|||
addWebhookAddRoutes := func() {
|
||||
m.Get("/{type}/new", repo_setting.WebhooksNew)
|
||||
m.Post("/gogs/new", web.Bind(forms.NewGogshookForm{}), repo_setting.GogsHooksNewPost)
|
||||
m.Post("/slack/new", web.Bind(forms.NewSlackHookForm{}), repo_setting.SlackHooksNewPost)
|
||||
m.Post("/discord/new", web.Bind(forms.NewDiscordHookForm{}), repo_setting.DiscordHooksNewPost)
|
||||
m.Post("/dingtalk/new", web.Bind(forms.NewDingtalkHookForm{}), repo_setting.DingtalkHooksNewPost)
|
||||
m.Post("/telegram/new", web.Bind(forms.NewTelegramHookForm{}), repo_setting.TelegramHooksNewPost)
|
||||
|
@ -416,7 +415,6 @@ func registerRoutes(m *web.Route) {
|
|||
|
||||
addWebhookEditRoutes := func() {
|
||||
m.Post("/gogs/{id}", web.Bind(forms.NewGogshookForm{}), repo_setting.GogsHooksEditPost)
|
||||
m.Post("/slack/{id}", web.Bind(forms.NewSlackHookForm{}), repo_setting.SlackHooksEditPost)
|
||||
m.Post("/discord/{id}", web.Bind(forms.NewDiscordHookForm{}), repo_setting.DiscordHooksEditPost)
|
||||
m.Post("/dingtalk/{id}", web.Bind(forms.NewDingtalkHookForm{}), repo_setting.DingtalkHooksEditPost)
|
||||
m.Post("/telegram/{id}", web.Bind(forms.NewTelegramHookForm{}), repo_setting.TelegramHooksEditPost)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue