-
Notifications
You must be signed in to change notification settings - Fork 101
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
List users in a room and invite users #90
Conversation
It looks like the downstream events/messages would happen multiple times which could result in a user receiving multiple invites. |
Changed Also modified the function to accept a callback, to be used after the user data is retrieved. The previous code snippet I posted now becomes:
This way, users writing scripts need not deal with adapter events, and also, we ensure that there are no memory leaks: |
usersInRoom = (item.attrs.name for item in userItems) | ||
@robot.logger.debug "[users in room] #{roomJID} has #{usersInRoom}" | ||
|
||
@emit "completedRequest#{stanza.attrs.id}", usersInRoom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sneaky 😄
List users in a room and invite users
This adds functionality to invite users to rooms, as well as the ability to list the users in a room.
Borrows the invite code from #72 with tests added.
For the list feature, a custom event
receivedUsersForRoom
is emitted after the server response is successfully parsed, and scripts can listen to it to get the list of users. Let me know if other approach makes sense (saving the data in hubot brain?).The xmpp specification leaves it up to the client to discard the invites if the user is already in the room, but clients do not seem to follow it (pidgin and gajim at least). I added the functionality to list the users in a room, so that scripts can use it to check if a user is already in the room, and if they are not, send the invite. Something like:
Not entirely sure what happens when there are concurrent requests for
getUsersInRoom()
, but right now, we are calling it only once at a time.The list functionality should also be useful in other cases. There's an open issue regarding this in the hubot repo: hubotio/hubot#742