You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/03/02 15:04:47 UTC

[GitHub] [camel] Kinae commented on a change in pull request #5121: CAMEL-16255 Use of the slack-api-model to create rich content

Kinae commented on a change in pull request #5121:
URL: https://github.com/apache/camel/pull/5121#discussion_r585641381



##########
File path: components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java
##########
@@ -118,23 +101,12 @@ private void verifyCredentials(ResultBuilder builder, Map<String, Object> parame
             String token = (String) parameters.get("token");
 
             try {
-                HttpClient client = HttpClientBuilder.create().useSystemProperties().build();
-                HttpPost httpPost = new HttpPost(parameters.get("serverUrl") + "/api/conversations.list");
-
-                List<BasicNameValuePair> params = new ArrayList<>();
-                params.add(new BasicNameValuePair("token", token));
-                httpPost.setEntity(new UrlEncodedFormEntity(params));
+                ConversationsListResponse response = Slack.getInstance(new CustomSlackHttpClient()).methods(token)
+                        .conversationsList(req -> req
+                                .types(Collections.singletonList(ConversationType.PUBLIC_CHANNEL))

Review comment:
       Very good question, I created an empty slack workspace and for now it's impossible to remove all public channel. You can't delete the general one. 
   
   So I tried with the opposite side, asked to list all private channels without having any and it replies 200 with this : 
   ```
   {
       "ok": true,
       "channels": [],
       "response_metadata": {
           "next_cursor": ""
       }
   }
   ```

##########
File path: components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java
##########
@@ -118,23 +101,12 @@ private void verifyCredentials(ResultBuilder builder, Map<String, Object> parame
             String token = (String) parameters.get("token");
 
             try {
-                HttpClient client = HttpClientBuilder.create().useSystemProperties().build();
-                HttpPost httpPost = new HttpPost(parameters.get("serverUrl") + "/api/conversations.list");
-
-                List<BasicNameValuePair> params = new ArrayList<>();
-                params.add(new BasicNameValuePair("token", token));
-                httpPost.setEntity(new UrlEncodedFormEntity(params));
+                ConversationsListResponse response = Slack.getInstance(new CustomSlackHttpClient()).methods(token)
+                        .conversationsList(req -> req
+                                .types(Collections.singletonList(ConversationType.PUBLIC_CHANNEL))

Review comment:
       Very good question, I created an empty Slack workspace and for now it's impossible to remove all public channel. You can't delete the general one. 
   
   So I tried with the opposite side, asked to list all private channels without having any and it replies 200 with this : 
   ```
   {
       "ok": true,
       "channels": [],
       "response_metadata": {
           "next_cursor": ""
       }
   }
   ```




----------------------------------------------------------------
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:
users@infra.apache.org