Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-14143

Slack Component: Consumer does not retrieve user details on message event

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.24.3, 3.0.0, 2.25.0
    • Component/s: camel-slack
    • Labels:
      None
    • Patch Info:
      Patch Available
    • Estimated Complexity:
      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.

       

       

        Attachments

        1. slack.patch
          2 kB
          Andy Krohg

          Activity

            People

            • Assignee:
              acosentino Andrea Cosentino
              Reporter:
              akrohg Andy Krohg
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: