Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
Patch Available
-
Novice
Description
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:
{ "client_msg_id":"6d1d3108-cf2a-4475-941c-0dd70200e88a", "type":"message", "text":"hello", "user":"UMQLDBWQY", "ts":"1572977454.000200", "team":"T0383HKJ0" }
The SlackEndpoint class still looks for the username attribute when creating the exchange, so the SlackMessage object comes out pretty bare.
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; }
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.