hubotio / hubot

A customizable life embetterment robot.

Home Page:https://hubotio.github.io/hubot/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does `Response.envelope` really need include the `message` object too?

joeyguerra opened this issue · comments

  constructor (robot, message, match) {
    this.robot = robot
    this.message = message
    this.match = match
    this.envelope = {
      room: this.message.room,
      user: this.message.user,
      message: this.message
    }
  }

The Response constructor sets envelope with the message but Response already has that message property. It's duplicated. Does it really need to be in envelope?

The envelope is what is passed to adapters, ie:

return await this.robot.adapter[methodName](this.envelope, ...context.strings)

You'd have to take a close look at adapters in the repo and in the wild to see what they are doing, and the difference. I don't remember if I was around when it was added, but my intuition would be to keep it a simple javascript object that is the interface, rather than passing message classes around. That might be moot though, since message in turn is also included in it.

I see your point. The envelope contains the original message object, and since the envelope is the thing that gets passed around, that's how other objects can get the message. I'll review other adapters to see how and if it's being used in the wild.

I agree with your point about keeping it a POJO instead of codifying it as a Class. Hubot, in general, is a message connector between two systems, so it makes sense to "just pass it through".