From b01d6f94e994eeef4ee4c837accecfdb3834007a Mon Sep 17 00:00:00 2001 From: Melissa Noelle Date: Fri, 9 Jan 2015 14:12:52 -0500 Subject: [PATCH] Create new Candy.Core.Contact for invites, add inRoster boolean to object. --- src/core/contact.js | 9 +++++++-- src/core/event.js | 7 ++++--- 2 files changed, 11 insertions(+), 5 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..bd4d6baf 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; @@ -482,8 +483,8 @@ 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')); + var fromUser = new Candy.Core.Contact; + fromUser.data.jid = Candy.Core.getRoster().get(msg.attr('from')); /* * (Candy.Core.Chatroom) room - @@ -493,7 +494,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'),