This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.18.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit cc237b9290137677fa82018247b1e13b7d7cd575 Author: Zineb BENDHIBA <[email protected]> AuthorDate: Wed Dec 7 19:33:33 2022 +0100 CAMEL-18805: Telegram : Fix unregister webhook API method (#8862) --- .../telegram/service/TelegramServiceRestBotAPIAdapter.java | 7 ++++++- .../camel/component/telegram/TelegramWebhookRegistrationTest.java | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java index 4a1934e1f3f..a207af7f294 100644 --- a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java +++ b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/service/TelegramServiceRestBotAPIAdapter.java @@ -190,7 +190,12 @@ public class TelegramServiceRestBotAPIAdapter implements TelegramService { @Override public boolean removeWebhook() { - return setWebhook(""); + final String uri = baseUri + "/deleteWebhook"; + + final HttpRequest.Builder request = HttpRequest.newBuilder().uri(URI.create(uri)).GET(); + + WebhookResult res = sendSyncRequest(request.build(), WebhookResult.class); + return res.isOk() && res.isResult(); } @Override diff --git a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramWebhookRegistrationTest.java b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramWebhookRegistrationTest.java index 9c4a2a5cbb7..876342dfe3e 100644 --- a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramWebhookRegistrationTest.java +++ b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramWebhookRegistrationTest.java @@ -136,6 +136,11 @@ public class TelegramWebhookRegistrationTest extends TelegramTestSupport { "setWebhook?url=http://my-domain.com/my-test", "GET", String.class, + TelegramTestUtil.serialize(result)) + .addEndpoint( + "deleteWebhook", + "GET", + String.class, TelegramTestUtil.serialize(result)); }
