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

[WIP] candy:core.presence.leave triggerHandler #6

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions src/core/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,19 +673,21 @@ Candy.Core.Event = (function(self, Strophe, $) {
* Also triggered when the local client gets kicked or banned from a room.
*
* Parameters:
* (String) roomJid - Room
* (String) roomName - Name of room
* (Candy.Core.Chatroom) room -
* (String) type - Presence type [kick, ban, leave]
* (String) reason - When type equals kick|ban, this is the reason the moderator has supplied.
* (String) actor - When type equals kick|ban, this is the moderator which did the kick
* (Candy.Core.Chatuser) actor - When type equals kick|ban, this is the moderator which did the kick
* (Candy.Core.ChatUser) user - user which leaves the room
*/

var room = Candy.Core.getRoom(roomJid)
var actorUser = Candy.Core.getRoster(actor);
Copy link
Member

Choose a reason for hiding this comment

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

The tricky thing here is that the moderator does not necessarily need to be in the room at the time that she kicks another user who is.

@bklang How much do we care to deal with this edge case?

Copy link
Author

Choose a reason for hiding this comment

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

Hah, there's also a bug here, it should read: Candy.Core.getRoster().get(actor);. :)

Could be as simple as checking to see if the actor exists? I generally feel like fixing edge case bugs helps prevent strange/tricky bugs in the future.

Copy link
Member

Choose a reason for hiding this comment

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

If it doesn't exist in our roster, we'd have to do similarly to elsewhere and allocate a temporary object. We should extract this somewhere common.

Copy link
Author

Choose a reason for hiding this comment

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

Is new Candy.Core.Contact not common enough? Where would you stick something like this?


$(Candy).triggerHandler('candy:core.presence.leave', {
'roomJid': roomJid,
'roomName': roomName,
'room': room,
'type': action,
'reason': reason,
'actor': actor,
'actor': actorUser,
'user': user
});
},
Expand Down