summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authoroliverpool <git@olivier.pfad.fr>2024-03-21 13:59:24 +0100
committeroliverpool <git@olivier.pfad.fr>2024-03-27 15:38:39 +0100
commit46b71ec709de88e7dc2addcb8ca33b97535549f6 (patch)
tree90030c449341f1f3f3b809fddbf03715e2424bb1 /routers
parent[REFACTOR] webhook dingtalk endpoint (diff)
downloadforgejo-46b71ec709de88e7dc2addcb8ca33b97535549f6.tar.xz
forgejo-46b71ec709de88e7dc2addcb8ca33b97535549f6.zip
[REFACTOR] webhook telegram endpoint
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/setting/webhook.go26
-rw-r--r--routers/web/web.go2
2 files changed, 0 insertions, 28 deletions
diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go
index 29b28cfd30..dc82475aae 100644
--- a/routers/web/repo/setting/webhook.go
+++ b/routers/web/repo/setting/webhook.go
@@ -388,32 +388,6 @@ func gogsHookParams(ctx *context.Context) webhookParams {
}
}
-// TelegramHooksNewPost response for creating Telegram webhook
-func TelegramHooksNewPost(ctx *context.Context) {
- createWebhook(ctx, telegramHookParams(ctx))
-}
-
-// TelegramHooksEditPost response for editing Telegram webhook
-func TelegramHooksEditPost(ctx *context.Context) {
- editWebhook(ctx, telegramHookParams(ctx))
-}
-
-func telegramHookParams(ctx *context.Context) webhookParams {
- form := web.GetForm(ctx).(*forms.NewTelegramHookForm)
-
- return webhookParams{
- Type: webhook_module.TELEGRAM,
- URL: fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage?chat_id=%s&message_thread_id=%s", url.PathEscape(form.BotToken), url.QueryEscape(form.ChatID), url.QueryEscape(form.ThreadID)),
- ContentType: webhook.ContentTypeJSON,
- WebhookForm: form.WebhookForm,
- Meta: &webhook_service.TelegramMeta{
- BotToken: form.BotToken,
- ChatID: form.ChatID,
- ThreadID: form.ThreadID,
- },
- }
-}
-
// MSTeamsHooksNewPost response for creating MSTeams webhook
func MSTeamsHooksNewPost(ctx *context.Context) {
createWebhook(ctx, mSTeamsHookParams(ctx))
diff --git a/routers/web/web.go b/routers/web/web.go
index 116ffccad5..7e41d7ed49 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -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("/telegram/new", web.Bind(forms.NewTelegramHookForm{}), repo_setting.TelegramHooksNewPost)
m.Post("/msteams/new", web.Bind(forms.NewMSTeamsHookForm{}), repo_setting.MSTeamsHooksNewPost)
m.Post("/feishu/new", web.Bind(forms.NewFeishuHookForm{}), repo_setting.FeishuHooksNewPost)
m.Post("/wechatwork/new", web.Bind(forms.NewWechatWorkHookForm{}), repo_setting.WechatworkHooksNewPost)
@@ -413,7 +412,6 @@ func registerRoutes(m *web.Route) {
addWebhookEditRoutes := func() {
m.Post("/gogs/{id}", web.Bind(forms.NewGogshookForm{}), repo_setting.GogsHooksEditPost)
- m.Post("/telegram/{id}", web.Bind(forms.NewTelegramHookForm{}), repo_setting.TelegramHooksEditPost)
m.Post("/msteams/{id}", web.Bind(forms.NewMSTeamsHookForm{}), repo_setting.MSTeamsHooksEditPost)
m.Post("/feishu/{id}", web.Bind(forms.NewFeishuHookForm{}), repo_setting.FeishuHooksEditPost)
m.Post("/wechatwork/{id}", web.Bind(forms.NewWechatWorkHookForm{}), repo_setting.WechatworkHooksEditPost)