Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Have message type default to groupchat

This is needed for compatibility with hubot methods like messageRoom
where Robot class has no knowledge of Jabber internals and calls #send()
with just id and room defined.
  • Loading branch information...
commit f258d662d8673f883d4b3daeeb194786fd6e3c6d 1 parent 3928cda
@ejfinneran ejfinneran authored
Showing with 15 additions and 1 deletion.
  1. +1 −1  src/xmpp.coffee
  2. +14 −0 test/adapter-test.coffee
View
2  src/xmpp.coffee
@@ -186,7 +186,7 @@ class XmppBot extends Adapter
params =
to: if user.type in ['direct', 'chat'] then "#{user.room}/#{user.id}" else user.room
- type: user.type
+ type: user.type or 'groupchat'
from: @options.username
message = new Xmpp.Element('message', params).
View
14 test/adapter-test.coffee
@@ -292,6 +292,20 @@ describe 'XmppBot', ->
logger:
debug: ->
+ it 'should use type groupchat if type is undefined', (done) ->
+ user =
+ id: 'mark'
+ room: 'test@example.com'
+
+ bot.client.send = (msg) ->
+ assert.equal msg.parent.attrs.to, 'test@example.com'
+ assert.equal msg.parent.attrs.type, 'groupchat'
+ assert.equal msg.parent.attrs.from, bot.options.username
+ assert.equal msg.getText(), 'testing'
+ done()
+
+ bot.send user, 'testing'
+
it 'should send messages directly', (done) ->
user =
id: 'mark'
Please sign in to comment.
Something went wrong with that request. Please try again.