From 12050d30adf92f392f6cb8ff7901d190f61e090b Mon Sep 17 00:00:00 2001 From: Federico Barrera Oro Date: Sun, 5 Apr 2020 19:46:13 -0300 Subject: [PATCH 1/3] Fix sendMessage Using the sendMessage, the text sent was always the first. Debugging HTTP response, I realized that the connector was appending the query params. The first time the call is going to be /bot/sendMessage?chat_id=1204698965&text=HelloHTTP/1.1 The second time the call is going to be /bot/sendMessage?chat_id=1204698965&chat_id=1204698965&text=Hello&text=ByeHTTP/1.1. The problem was fixed by only instantiating a new HttpRequest instead of using the once that was instantiated at the beginning. --- .../mule/telegram/internal/TelegramConnection.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/mule/extension/mule/telegram/internal/TelegramConnection.java b/src/main/java/org/mule/extension/mule/telegram/internal/TelegramConnection.java index 59acb4d..c5db40c 100644 --- a/src/main/java/org/mule/extension/mule/telegram/internal/TelegramConnection.java +++ b/src/main/java/org/mule/extension/mule/telegram/internal/TelegramConnection.java @@ -26,7 +26,6 @@ public final class TelegramConnection { private static final Logger LOGGER = LoggerFactory.getLogger(TelegramConnection.class); private TelegramConfiguration genConfig; private HttpClient httpClient; - private HttpRequestBuilder httpRequestBuilder; public TelegramConnection(HttpService httpService, TelegramConfiguration gConfig) { genConfig = gConfig; @@ -37,7 +36,6 @@ public void initHttpClient(HttpService httpService){ HttpClientConfiguration.Builder builder = new HttpClientConfiguration.Builder(); builder.setName("telegram"); httpClient = httpService.getClientFactory().create(builder.build()); - httpRequestBuilder = HttpRequest.builder(); httpClient.start(); } @@ -57,7 +55,7 @@ public InputStream sendMessage(String chatId, String message){ qParams.put("chat_id", chatId); qParams.put("text", message); - HttpRequest request = httpRequestBuilder + HttpRequest request = HttpRequest.builder() .method("GET") .uri(strUri) .queryParams(qParams) @@ -73,6 +71,7 @@ public InputStream sendMessage(String chatId, String message){ } catch (Exception e) { e.printStackTrace(); } + return null; } @@ -86,7 +85,7 @@ public InputStream getUpdates(String chatId, boolean watermark, String lastUpdat qParams.put("offset", lastUpdateId); } - HttpRequest request = httpRequestBuilder + HttpRequest request = HttpRequest.builder() .method("GET") .uri(strUri) .queryParams(qParams) From d6b8a607df47ea33c74decc159f9879fb1299b21 Mon Sep 17 00:00:00 2001 From: Federico Barrera Oro Date: Sun, 5 Apr 2020 23:29:52 -0300 Subject: [PATCH 2/3] Updating gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 636d33a..a9b5944 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,7 @@ src/main/api/.repository/ src/main/api/.gitignore velocity.log target/ -.idea/ \ No newline at end of file +.idea/ +bin/ +.settings/ +.project From 71123a471f9a687fade9bf1ad8b3497a4079193d Mon Sep 17 00:00:00 2001 From: Federico Barrera Oro Date: Mon, 6 Apr 2020 12:13:52 -0300 Subject: [PATCH 3/3] Update Listener to make chat id optional --- .../mule/telegram/internal/sources/UpdatesListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/mule/extension/mule/telegram/internal/sources/UpdatesListener.java b/src/main/java/org/mule/extension/mule/telegram/internal/sources/UpdatesListener.java index 15d04bd..be17790 100644 --- a/src/main/java/org/mule/extension/mule/telegram/internal/sources/UpdatesListener.java +++ b/src/main/java/org/mule/extension/mule/telegram/internal/sources/UpdatesListener.java @@ -53,6 +53,7 @@ public class UpdatesListener extends PollingSource { @Parameter + @Optional protected String chatId; @Parameter