Claus Ibsen created CAMEL-27687:
-----------------------------------
Summary: camel-telegram: proxyType unused, webhook URL not
encoded, required token, header labels
Key: CAMEL-27687
URL: https://issues.apache.org/jira/browse/CAMEL-27687
Project: Camel
Issue Type: Bug
Components: camel-telegram
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-telegram for CAMEL-23832
(PR (commit
https://github.com/apache/camel/commit/e18e8040dca35f096c41aac055daae53c35c5e30)).
These are separate problems of the component; the descriptions commit only
documents the current behavior.
h4. 1. proxyType has no effect
{{TelegramEndpoint.doStart()}} only logs {{proxyType}} and always builds
{{ProxySelector.of(new InetSocketAddress(proxyHost, proxyPort))}}, which is an
HTTP proxy. A user who sets {{proxyType=SOCKS4}} or {{SOCKS5}} silently gets an
HTTP proxy. {{java.net.http.HttpClient}} does not support SOCKS proxies.
Proposed change: deprecate {{proxyType}} (or fail at startup for a SOCKS
value), and document that only HTTP proxies are supported.
h4. 2. setWebhook does not URL-encode the webhook URL
{{TelegramServiceRestBotAPIAdapter.setWebhook(String, String)}} builds
{{baseUri + "/setWebhook?url=" + url}} without encoding {{url}}. A webhook URL
with a query string of more than one parameter is cut at the first {{&}}, and
the rest becomes parameters of the Bot API call, so Telegram registers a
different URL.
Proposed change: encode the URL with {{URLEncoder.encode(url,
StandardCharsets.UTF_8)}}, as is already done for {{secret_token}}.
h4. 3. Endpoint option authorizationToken is marked required
The endpoint option {{authorizationToken}} in {{TelegramConfiguration}} has
{{@Metadata(required = true)}}, but {{TelegramComponent.createEndpoint()}}
takes it from the component option {{authorizationToken}} when the endpoint
does not set it. Tools that read the catalog report a valid endpoint URI as
missing a required option.
Proposed change: drop {{required = true}} and keep the check in
{{createEndpoint()}}.
h4. 4. Header labels missing or incomplete
In {{TelegramConstants}}, {{CamelTelegramMediaType}},
{{CamelTelegramMediaTitleCaption}}, {{CamelTelegramMediaMarkup}} and
{{CamelTelegramParseMode}} have no label, although only the producer reads
them. {{CamelMessageTimestamp}} has no label, although only the consumer sets
it. {{CamelTelegramChatId}} is labelled {{producer}} only, although the
consumer sets it too ({{TelegramMessageHelper.populateExchange()}}).
Proposed change: label the four media headers {{producer}},
{{CamelMessageTimestamp}} {{consumer}}, and {{CamelTelegramChatId}}
{{consumer,producer}}.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)