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 998242f7..a188c095 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(); } @@ -474,7 +483,7 @@ Candy.Core.Event = (function(self, Strophe, $) { invite = { roomJid: msg.attr('from'), - from: mediatedInvite.attr('from'), + from: fromUser, reason: reason, password: password, continuedThread: continueNode.attr('thread') @@ -482,15 +491,27 @@ Candy.Core.Event = (function(self, Strophe, $) { } if(directInvite.length > 0) { + 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; + } invite = { roomJid: directInvite.attr('jid'), - from: msg.attr('from'), + from: fromUser, reason: directInvite.attr('reason'), password: directInvite.attr('password'), continuedThread: directInvite.attr('thread') }; } + /* + * (Candy.Core.Chatroom) room - + * (Candy.Core.Contact) from - + * (String) reason - + * (String) password - + * (String) continuedThread - + */ return invite; },