From 5c7205e4b32832383a65a138e64ae5ef436d76ed Mon Sep 17 00:00:00 2001 From: Melissa Noelle Date: Wed, 7 Jan 2015 13:02:11 -0500 Subject: [PATCH 1/3] Added in room and contact objects to invite for candy:core:chat:invite. --- src/core/event.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/event.js b/src/core/event.js index 998242f7..fe66a017 100644 --- a/src/core/event.js +++ b/src/core/event.js @@ -482,9 +482,19 @@ Candy.Core.Event = (function(self, Strophe, $) { } if(directInvite.length > 0) { + fromUser = Candy.Core.getRoster().get(msg.attr('from')); + room = Candy.Core.getRoom(directInvite.attr('jid')); + + /* + * (Candy.Core.Chatroom) room - + * (Candy.Core.Contact) from - + * (String) reason - + * (String) password - + * (String) continuedThread - + */ invite = { - roomJid: directInvite.attr('jid'), - from: msg.attr('from'), + room: room, + from: fromUser, reason: directInvite.attr('reason'), password: directInvite.attr('password'), continuedThread: directInvite.attr('thread') From 3d9ee4aef94bdc675c6c86c564128519f02fa1e7 Mon Sep 17 00:00:00 2001 From: Melissa Noelle Date: Fri, 9 Jan 2015 14:12:52 -0500 Subject: [PATCH 2/3] Create new Candy.Core.Contact for invites, add inRoster boolean to object. --- src/core/contact.js | 9 +++++++-- src/core/event.js | 22 ++++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/core/contact.js b/src/core/contact.js index 04c3cf50..fb684a5f 100644 --- a/src/core/contact.js +++ b/src/core/contact.js @@ -19,10 +19,11 @@ Candy.Core.Contact = function(stropheRosterItem) { /** Object: data * Strophe Roster plugin item model containing: - * - jid - * - name + * - (String) jid + * - (String) name * - subscription * - groups + * - (Boolean) inRoster */ this.data = stropheRosterItem; }; @@ -134,6 +135,10 @@ Candy.Core.Contact.prototype.getStatus = function() { return status; }; +Candy.Core.Contact.prototype.isInRoster = function() { + return this.data.inRoster; +} + Candy.Core.Contact.prototype._weightForStatus = function(status) { switch (status) { case 'chat': diff --git a/src/core/event.js b/src/core/event.js index fe66a017..1fa6d204 100644 --- a/src/core/event.js +++ b/src/core/event.js @@ -264,6 +264,7 @@ Candy.Core.Event = (function(self, Strophe, $) { }, _addRosterItem: function(item) { + item.inRoster = true; var user = new Candy.Core.Contact(item); Candy.Core.getRoster().add(user); return user; @@ -457,6 +458,8 @@ Candy.Core.Event = (function(self, Strophe, $) { directInvite = msg.find('x[xmlns="jabber:x:conference"]'), invite; + var fromUser; + if(mediatedInvite.length > 0) { var passwordNode = msg.find('password'), password, @@ -464,6 +467,12 @@ Candy.Core.Event = (function(self, Strophe, $) { reason, continueNode = mediatedInvite.find('continue'); + if (!fromUser = Candy.Core.getRoster().get(mediatedInvite.attr('from'))) { + var fromUser = new Candy.Core.Contact; + fromUser.data.jid = mediatedInvite.attr('from'); + fromUser.data.inRoster = false; + } + if(passwordNode.text() !== '') { password = passwordNode.text(); } @@ -472,9 +481,11 @@ Candy.Core.Event = (function(self, Strophe, $) { reason = reasonNode.text(); } + fromUser.jid = mediatedInvite.attr('from'); + invite = { roomJid: msg.attr('from'), - from: mediatedInvite.attr('from'), + from: fromUser, reason: reason, password: password, continuedThread: continueNode.attr('thread') @@ -482,8 +493,11 @@ Candy.Core.Event = (function(self, Strophe, $) { } if(directInvite.length > 0) { - fromUser = Candy.Core.getRoster().get(msg.attr('from')); - room = Candy.Core.getRoom(directInvite.attr('jid')); + if (!fromUser = Candy.Core.getRoster().get(msg.attr('from'))) { + var fromUser = new Candy.Core.Contact; + fromUser.data.jid = msg.attr('from'); + fromUser.data.inRoster = false; + } /* * (Candy.Core.Chatroom) room - @@ -493,7 +507,7 @@ Candy.Core.Event = (function(self, Strophe, $) { * (String) continuedThread - */ invite = { - room: room, + roomJid: directInvite.attr('jid'), from: fromUser, reason: directInvite.attr('reason'), password: directInvite.attr('password'), From 7f679049a7ec12335173762ad9e411e832fa96c0 Mon Sep 17 00:00:00 2001 From: Melissa Noelle Date: Fri, 9 Jan 2015 14:33:01 -0500 Subject: [PATCH 3/3] Removing extraneous line. --- src/core/event.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/core/event.js b/src/core/event.js index 1fa6d204..a188c095 100644 --- a/src/core/event.js +++ b/src/core/event.js @@ -481,8 +481,6 @@ Candy.Core.Event = (function(self, Strophe, $) { reason = reasonNode.text(); } - fromUser.jid = mediatedInvite.attr('from'); - invite = { roomJid: msg.attr('from'), from: fromUser, @@ -498,14 +496,6 @@ Candy.Core.Event = (function(self, Strophe, $) { fromUser.data.jid = msg.attr('from'); fromUser.data.inRoster = false; } - - /* - * (Candy.Core.Chatroom) room - - * (Candy.Core.Contact) from - - * (String) reason - - * (String) password - - * (String) continuedThread - - */ invite = { roomJid: directInvite.attr('jid'), from: fromUser, @@ -515,6 +505,13 @@ Candy.Core.Event = (function(self, Strophe, $) { }; } + /* + * (Candy.Core.Chatroom) room - + * (Candy.Core.Contact) from - + * (String) reason - + * (String) password - + * (String) continuedThread - + */ return invite; },