Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of xmpp.jid() #366

Closed
cburschka opened this issue Apr 23, 2016 · 1 comment
Closed

Get rid of xmpp.jid() #366

cburschka opened this issue Apr 23, 2016 · 1 comment

Comments

@cburschka
Copy link
Owner

cburschka commented Apr 23, 2016

#292 tried to solve a very real problem - all kinds of code was expecting a room/nick, and couldn't handle different kinds of JID.

For some reason, the solution was to make such code accept an object with various keys. That object would then be turned into a JID according to complex and hard to explain rules.

This led to code having to pass undefined to get the current room broadcast address, {} to get the domain, {room: null} to get the MUC domain, and {jid: '..'} to pass through a JID directly.

The sane way, I now realize, is to simply make all functions expect a JID. domain values can be taken directly from the configuration, a jid can be passed directly, and the only thing remaining is a function that turns a roomnick into a JID.


  /**
   * Generate a JID from a roomnick.
   *
   * @param {string} room (defaults to current room)
   * @param {string} nick (leave empty for groupchat)
   *
   */
  jidFromRoomNick: function({room, nick}={}) {
    return new this.JID({
      domain: config.xmpp.mucService,
      node: room || this.room.current,
      resource: nick
    });
  },

@cburschka cburschka self-assigned this Apr 23, 2016
@cburschka cburschka added this to the 1.12.0 - Trixie milestone Apr 23, 2016
cburschka added a commit that referenced this issue Apr 23, 2016
This is voodoo. We just need an xmpp.jidFromRoomNick(),
everything else can be passed directly.
@cburschka
Copy link
Owner Author

Ironically, the function actually used to be called jidFromRoomNick.

The sole problem was that it took positional arguments - and, of course, that it was called by .pres/.msg/ instead of their callers.

cburschka added a commit that referenced this issue Apr 24, 2016
This is voodoo. We just need an xmpp.jidFromRoomNick(),
everything else can be passed directly.
cburschka added a commit that referenced this issue May 19, 2016
This is voodoo. We just need an xmpp.jidFromRoomNick(),
everything else can be passed directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant