Permalink
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...
1 parent 3928cda commit f258d662d8673f883d4b3daeeb194786fd6e3c6d @ejfinneran ejfinneran committed Jan 21, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 src/xmpp.coffee
  2. +14 −0 test/adapter-test.coffee
View
@@ -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
@@ -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'

0 comments on commit f258d66

Please sign in to comment.