Commit 05e7cc85 authored by JC Brand's avatar JC Brand

Let `api.contacts.get` return the RosterContact model

parent daff088c
......@@ -695,7 +695,9 @@ To return all contacts, simply call ``get`` without any parameters:
});
The returned roster contact objects have these attributes:
The returned roster contact is a `Backbone.Model <http://backbonejs.org/#Model>`_ of type _converse.RosterContacts.
It has the following attributes (which should be accessed via `get <http://backbonejs.org/#Model-get>`_).
+----------------+-----------------------------------------------------------------------------------------------------------------+
| Attribute | |
......
......@@ -1929,19 +1929,15 @@
},
'contacts': {
'get' (jids) {
const _transform = function (jid) {
const contact = _converse.roster.get(Strophe.getBareJidFromJid(jid));
if (contact) {
return contact.attributes;
}
return null;
const _getter = function (jid) {
return _converse.roster.get(Strophe.getBareJidFromJid(jid)) || null;
};
if (_.isUndefined(jids)) {
jids = _converse.roster.pluck('jid');
} else if (_.isString(jids)) {
return _transform(jids);
return _getter(jids);
}
return _.map(jids, _transform);
return _.map(jids, _getter);
},
'add' (jid, name) {
if (!_.isString(jid) || !_.includes(jid, '@')) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment