Skip to content

Commit b01d6f9

Browse files
author
Melissa Noelle
committed
Create new Candy.Core.Contact for invites, add inRoster boolean to object.
1 parent 5c7205e commit b01d6f9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/core/contact.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
Candy.Core.Contact = function(stropheRosterItem) {
2020
/** Object: data
2121
* Strophe Roster plugin item model containing:
22-
* - jid
23-
* - name
22+
* - (String) jid
23+
* - (String) name
2424
* - subscription
2525
* - groups
26+
* - (Boolean) inRoster
2627
*/
2728
this.data = stropheRosterItem;
2829
};
@@ -134,6 +135,10 @@ Candy.Core.Contact.prototype.getStatus = function() {
134135
return status;
135136
};
136137

138+
Candy.Core.Contact.prototype.isInRoster = function() {
139+
return this.data.inRoster;
140+
}
141+
137142
Candy.Core.Contact.prototype._weightForStatus = function(status) {
138143
switch (status) {
139144
case 'chat':

src/core/event.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ Candy.Core.Event = (function(self, Strophe, $) {
264264
},
265265

266266
_addRosterItem: function(item) {
267+
item.inRoster = true;
267268
var user = new Candy.Core.Contact(item);
268269
Candy.Core.getRoster().add(user);
269270
return user;
@@ -482,8 +483,8 @@ Candy.Core.Event = (function(self, Strophe, $) {
482483
}
483484

484485
if(directInvite.length > 0) {
485-
fromUser = Candy.Core.getRoster().get(msg.attr('from'));
486-
room = Candy.Core.getRoom(directInvite.attr('jid'));
486+
var fromUser = new Candy.Core.Contact;
487+
fromUser.data.jid = Candy.Core.getRoster().get(msg.attr('from'));
487488

488489
/*
489490
* (Candy.Core.Chatroom) room -
@@ -493,7 +494,7 @@ Candy.Core.Event = (function(self, Strophe, $) {
493494
* (String) continuedThread -
494495
*/
495496
invite = {
496-
room: room,
497+
roomJid: directInvite.attr('jid'),
497498
from: fromUser,
498499
reason: directInvite.attr('reason'),
499500
password: directInvite.attr('password'),

0 commit comments

Comments
 (0)