rocketchat-jira-trigger icon indicating copy to clipboard operation
rocketchat-jira-trigger copied to clipboard

FromRocketChatMessage data object outdated

Open zugao opened this issue 5 years ago • 2 comments

In the logs there's always this warn: 2020-04-15 09:50:22,181 [qtp1667043665-64] WARN s.g.r.s.r.RocketChatMessageRoute - Invalid JSON in request body: Expected a boolean but was BEGIN_OBJECT at line 1 column 44 path $.bot

After checking the code I noticed that the class FromRocketChatMessage is outdated in regards to the message received from newest version of RocketChat, "bot" field is not a boolean anymore. Can we expect an update? Or any review from your part in case I open a PullRequest?

zugao avatar Jul 16 '20 13:07 zugao

I'm not actively maintaining this anymore. I'll happily take a look at a PR, if you provide the appropriate tests (some screenshots would be cool too). But keep in mind that changing the data type of a property might break older clients.

gustavkarlsson avatar Aug 29 '20 13:08 gustavkarlsson

In case anybody is wondering what is going on with this error:

I imagine it is because rocket.chat used to send whether a message is from a bot or not via a simple boolean flag. But now apparently rocket.chat sends some sort of user token when a message is from a bot instead of a flag. On the other hand, when a message is not from a bot, rocket.chat sends a flag like it used to. This is in my opinion horrible, horrible API design because the data type of the "bot" flag changes all the time.

This issue is by the way the exact same issue as #74. Apparently, the rocketchat-jira-trigger sends a 404 error when the provided json does not conform to the expected structure.

I have found a workaround for this. In the outgoing webhook configuration of your rocket.chat server activate the script and paste the following in there:

class Script {

  prepare_outgoing_request({ request }) {
    if (request.data.bot !== undefined && request.data.bot !== false) {
      var botRequest = Object.assign({}, request);
      botRequest.data.bot = true;
      return botRequest;
    }
    return request;
  }

}

dscheffer avatar Mar 03 '21 12:03 dscheffer