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

join room on invitation #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/xmpp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ class XmppBot extends Adapter
@client.send pong

readMessage: (stanza) =>

if (x = stanza.getChild('x', 'jabber:x:conference')) and x?.attrs?
@robot.logger.debug '[joining room]', x.attrs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is in x.attrs are there password that shouldn't go into logs?

@options.rooms.push x.attrs
@joinRoom x.attrs

# ignore non-messages
return if stanza.attrs.type not in ['groupchat', 'direct', 'chat']
return if stanza.attrs.from is undefined
Expand Down
30 changes: 30 additions & 0 deletions test/adapter-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,36 @@ describe 'XmppBot', ->
done()
bot.joinRoom protectedRoom

describe '#invites', ->

it 'joins when invited', (done) ->

bot = Bot.use()

bot.client =
stub: 'xmpp client'

bot.robot =
name: 'bot'
logger:
debug: () ->
room =
jid: 'test@example.com'
password: false

stanza = new Xmpp.Stanza 'message'
stanza.c 'x', {xmlns: 'jabber:x:conference', jid: room.jid, password: room.password}

bot.options = {rooms:[]}

bot.joinRoom = (r) ->
assert r.jid is room.jid, 'jid match'
assert r.password is room.password, 'password match'
done()

bot.readMessage.call bot, stanza


describe '#leaveRoom()', ->
bot = Bot.use()
bot.client =
Expand Down