You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Andrea Cosentino (Jira)" <ji...@apache.org> on 2019/11/05 20:16:00 UTC

[jira] [Assigned] (CAMEL-14143) Slack Component: Consumer does not retrieve user details on message event

     [ https://issues.apache.org/jira/browse/CAMEL-14143?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrea Cosentino reassigned CAMEL-14143:
----------------------------------------

    Assignee: Andrea Cosentino

> Slack Component: Consumer does not retrieve user details on message event
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-14143
>                 URL: https://issues.apache.org/jira/browse/CAMEL-14143
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-slack
>            Reporter: Andy Krohg
>            Assignee: Andrea Cosentino
>            Priority: Major
>         Attachments: slack.patch
>
>
> The JSON object that Slack delivers for message events no longer sends a *username* attribute; it issues the user's *GUID* in the *user* field. For example:
>  
> {code:java}
> {
>         "client_msg_id":"6d1d3108-cf2a-4475-941c-0dd70200e88a",
>         "type":"message",
>         "text":"hello",
>         "user":"UMQLDBWQY",
>         "ts":"1572977454.000200",
>         "team":"T0383HKJ0"
> }
> {code}
> The SlackEndpoint class still looks for the *username* attribute when creating the exchange, so the SlackMessage object comes out pretty bare.
> {code:java}
>     public Exchange createExchange(ExchangePattern pattern, JsonObject object) {
>         Exchange exchange = super.createExchange(pattern);
>         SlackMessage slackMessage = new SlackMessage();
>         String text = object.getString("text");
>         String username = object.getString("username");
>         slackMessage.setText(text);
>         slackMessage.setUsername(username);
>         if (ObjectHelper.isNotEmpty(object.get("icons"))) {
>             JsonObject icons = object.getMap("icons");
>             if (ObjectHelper.isNotEmpty(icons.get("emoji"))) {
>                 slackMessage.setIconEmoji(icons.getString("emoji"));
>             }
>         }
>         Message message = exchange.getIn();
>         message.setBody(slackMessage);
>         return exchange;
>     }
> {code}
> I've attached a .patch that retrieves the user's *GUID* instead, so it's at least available if people using this component want to look up the username with the [users.info API|https://api.slack.com/methods/users.info/test].
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)