Kinae commented on a change in pull request #5121: URL: https://github.com/apache/camel/pull/5121#discussion_r585649143
########## File path: components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java ########## @@ -141,68 +129,40 @@ public int processBatch(Queue<Object> exchanges) throws Exception { return total; } - private String getChannelId(String channel) throws IOException, DeserializationException { - HttpPost httpPost = new HttpPost(slackEndpoint.getServerUrl() + "/api/conversations.list"); - - List<BasicNameValuePair> params = new ArrayList<>(); - params.add(new BasicNameValuePair("token", slackEndpoint.getToken())); - httpPost.setEntity(new UrlEncodedFormEntity(params)); - - HttpResponse response = client.execute(httpPost); - - String jsonString = readResponse(response); - JsonObject c = (JsonObject) Jsoner.deserialize(jsonString); - - checkSlackReply(c); - - Collection<JsonObject> channels = c.getCollection("channels"); - if (channels == null) { - throw new RuntimeCamelException("The response was successful but no channel list was provided"); - } - - for (JsonObject singleChannel : channels) { - if (singleChannel.get("name") != null) { - if (singleChannel.get("name").equals(channel)) { - if (singleChannel.get("id") != null) { - return (String) singleChannel.get("id"); - } - } + private String getChannelId(final String channel, final String cursor) { + try { + // Maximum limit is 1000. Slack recommends no more than 200 results at a time. + // https://api.slack.com/methods/conversations.list + ConversationsListResponse response = slack.methods(slackEndpoint.getToken()).conversationsList(req -> req + .types(Collections.singletonList(slackEndpoint.getConversationType())) + .cursor(cursor) + .limit(200)); Review comment: done ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org