From 0285b04f4ca981d7467097dbca3b281011b7798c Mon Sep 17 00:00:00 2001 From: Denys Konovalov Date: Sun, 17 Mar 2024 15:11:28 +0100 Subject: [PATCH] fix telegram webhook (#29864) Fix #29837 which is a regression caused by https://github.com/go-gitea/gitea/pull/29145/files#diff-731445ee00f0f1bf2ff731f4f96ddcf51cdc53fd2faaf406eb3536fc292ea748L48. The line was probably removed by accident. --------- Co-authored-by: Giteabot --- services/webhook/telegram.go | 4 +++- services/webhook/telegram_test.go | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/services/webhook/telegram.go b/services/webhook/telegram.go index e4a5b5a4246..c2b48200324 100644 --- a/services/webhook/telegram.go +++ b/services/webhook/telegram.go @@ -181,7 +181,9 @@ func (t telegramConvertor) Package(p *api.PackagePayload) (TelegramPayload, erro func createTelegramPayload(message string) TelegramPayload { return TelegramPayload{ - Message: strings.TrimSpace(message), + Message: strings.TrimSpace(message), + ParseMode: "HTML", + DisableWebPreview: true, } } diff --git a/services/webhook/telegram_test.go b/services/webhook/telegram_test.go index 27ab96cd09a..2fe5161b228 100644 --- a/services/webhook/telegram_test.go +++ b/services/webhook/telegram_test.go @@ -18,6 +18,15 @@ import ( func TestTelegramPayload(t *testing.T) { tc := telegramConvertor{} + + t.Run("Correct webhook params", func(t *testing.T) { + p := createTelegramPayload("testMsg ") + + assert.Equal(t, "HTML", p.ParseMode) + assert.Equal(t, true, p.DisableWebPreview) + assert.Equal(t, "testMsg", p.Message) + }) + t.Run("Create", func(t *testing.T) { p := createTestPayload()