Skip to content

Commit cbde2a1

Browse files
committed
Make the fetching of VCards optional. Updates conversejs#100
1 parent 7b2d16a commit cbde2a1

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

converse.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
this.show_only_online_users = false;
8888
this.show_emoticons = true;
8989
this.show_toolbar = true;
90+
this.use_vcards = true;
9091
this.xhr_custom_status = false;
9192
this.xhr_custom_status_url = '';
9293
this.xhr_user_search = false;
@@ -114,6 +115,7 @@
114115
'show_only_online_users',
115116
'show_toolbar',
116117
'sid',
118+
'use_vcards',
117119
'xhr_custom_status',
118120
'xhr_custom_status_url',
119121
'xhr_user_search',
@@ -205,6 +207,12 @@
205207
};
206208

207209
this.getVCard = function (jid, callback, errback) {
210+
if (!this.use_vcards) {
211+
if (callback) {
212+
callback(jid, jid);
213+
}
214+
return;
215+
}
208216
converse.connection.vcard.get(
209217
$.proxy(function (iq) {
210218
// Successful callback
@@ -242,7 +250,8 @@
242250
if (errback) {
243251
errback(iq);
244252
}
245-
});
253+
}
254+
);
246255
};
247256

248257
this.onConnect = function (status) {
@@ -1384,16 +1393,7 @@
13841393
$input.addClass('error');
13851394
return;
13861395
}
1387-
converse.getVCard(
1388-
jid,
1389-
$.proxy(function (jid, fullname, image, image_type, url) {
1390-
this.addContact(jid, fullname);
1391-
}, this),
1392-
$.proxy(function (stanza) {
1393-
converse.log("An error occured while fetching vcard");
1394-
var jid = $(stanza).attr('from');
1395-
this.addContact(jid, jid);
1396-
}, this));
1396+
this.addContact(jid);
13971397
$('.search-xmpp').hide();
13981398
},
13991399

@@ -1408,6 +1408,7 @@
14081408
},
14091409

14101410
addContact: function (jid, name) {
1411+
name = _.isEmpty(name)? jid: name;
14111412
converse.connection.roster.add(jid, name, [], function (iq) {
14121413
converse.connection.roster.subscribe(jid, null, converse.xmppstatus.get('fullname'));
14131414
});

docs/CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Changelog
55
------------------
66

77
* #48 Add event emitter support and emit events. [jcbrand]
8+
* #100 Make the fetching of vCards optional (enabled by default). [jcbrand]
89

910
0.7.1 (2013-11-17)
1011
------------------

docs/source/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,15 @@ Default = ``false``
815815
If set to ``true``, only online users will be shown in the contacts roster.
816816
Users with any other status (e.g. away, busy etc.) will not be shown.
817817

818+
use_vcards
819+
----------
820+
821+
Default = ``true``
822+
823+
Determines whether the XMPP server will be queried for roster contacts' VCards
824+
or not. VCards contain extra personal information such as your fullname and
825+
avatar image.
826+
818827
xhr_custom_status
819828
-----------------
820829

0 commit comments

Comments
 (0)