Commit c583678c authored by JC Brand's avatar JC Brand

Use `_coverse.api.sendIQ` instead of `_converse.connection.sendIQ`

So that we know an event will be emitted when the stanza is sent.
parent 6ebf6f6e
This diff is collapsed.
...@@ -3737,9 +3737,9 @@ ...@@ -3737,9 +3737,9 @@
})); }));
it("contains a link to a modal which can list groupchats publically available on the server", it("contains a link to a modal which can list groupchats publically available on the server",
mock.initConverseWithPromises( mock.initConverseWithPromises(
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {}, null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
function (done, _converse) { async function (done, _converse) {
var sendIQ = _converse.connection.sendIQ; var sendIQ = _converse.connection.sendIQ;
var sent_stanza, IQ_id; var sent_stanza, IQ_id;
...@@ -3753,53 +3753,49 @@ ...@@ -3753,53 +3753,49 @@
roomspanel.el.querySelector('.show-list-muc-modal').click(); roomspanel.el.querySelector('.show-list-muc-modal').click();
test_utils.closeControlBox(_converse); test_utils.closeControlBox(_converse);
const modal = roomspanel.list_rooms_modal; const modal = roomspanel.list_rooms_modal;
test_utils.waitUntil(() => u.isVisible(modal.el), 1000) await test_utils.waitUntil(() => u.isVisible(modal.el), 1000);
.then(() => { spyOn(_converse.ChatRoom.prototype, 'getRoomFeatures').and.callFake(() => Promise.resolve());
spyOn(_converse.ChatRoom.prototype, 'getRoomFeatures').and.callFake(() => Promise.resolve()); roomspanel.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
roomspanel.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
// See: http://xmpp.org/extensions/xep-0045.html#disco-rooms
// See: http://xmpp.org/extensions/xep-0045.html#disco-rooms expect(modal.el.querySelectorAll('.available-chatrooms li').length).toBe(0);
expect(modal.el.querySelectorAll('.available-chatrooms li').length).toBe(0);
const input = modal.el.querySelector('input[name="server"]').value = 'chat.shakespear.lit';
const input = modal.el.querySelector('input[name="server"]').value = 'chat.shakespear.lit'; modal.el.querySelector('input[type="submit"]').click();
modal.el.querySelector('input[type="submit"]').click(); await test_utils.waitUntil(() => _converse.chatboxes.length);
return test_utils.waitUntil(() => _converse.chatboxes.length); expect(sent_stanza.toLocaleString()).toBe(
}).then(() => { `<iq from="dummy@localhost/resource" id="${IQ_id}" to="chat.shakespear.lit" type="get" xmlns="jabber:client">`+
expect(sent_stanza.toLocaleString()).toBe( `<query xmlns="http://jabber.org/protocol/disco#items"/>`+
`<iq from="dummy@localhost/resource" id="${IQ_id}" to="chat.shakespear.lit" type="get" xmlns="jabber:client">`+ `</iq>`
`<query xmlns="http://jabber.org/protocol/disco#items"/>`+ );
`</iq>`
);
var iq = $iq({ const iq = $iq({
from:'muc.localhost', from:'muc.localhost',
to:'dummy@localhost/pda', to:'dummy@localhost/pda',
id: IQ_id, id: IQ_id,
type:'result' type:'result'
}).c('query') }).c('query')
.c('item', { jid:'heath@chat.shakespeare.lit', name:'A Lonely Heath'}).up() .c('item', { jid:'heath@chat.shakespeare.lit', name:'A Lonely Heath'}).up()
.c('item', { jid:'coven@chat.shakespeare.lit', name:'A Dark Cave'}).up() .c('item', { jid:'coven@chat.shakespeare.lit', name:'A Dark Cave'}).up()
.c('item', { jid:'forres@chat.shakespeare.lit', name:'The Palace'}).up() .c('item', { jid:'forres@chat.shakespeare.lit', name:'The Palace'}).up()
.c('item', { jid:'inverness@chat.shakespeare.lit', name:'Macbeth&apos;s Castle'}).nodeTree; .c('item', { jid:'inverness@chat.shakespeare.lit', name:'Macbeth&apos;s Castle'}).nodeTree;
_converse.connection._dataRecv(test_utils.createRequest(iq)); _converse.connection._dataRecv(test_utils.createRequest(iq));
expect(modal.el.querySelectorAll('.available-chatrooms li').length).toBe(5); await test_utils.waitUntil(() => modal.el.querySelectorAll('.available-chatrooms li').length === 5);
const rooms = modal.el.querySelectorAll('.available-chatrooms li'); const rooms = modal.el.querySelectorAll('.available-chatrooms li');
expect(rooms[0].textContent.trim()).toBe("Groupchats found:"); expect(rooms[0].textContent.trim()).toBe("Groupchats found:");
expect(rooms[1].textContent.trim()).toBe("A Lonely Heath"); expect(rooms[1].textContent.trim()).toBe("A Lonely Heath");
expect(rooms[2].textContent.trim()).toBe("A Dark Cave"); expect(rooms[2].textContent.trim()).toBe("A Dark Cave");
expect(rooms[3].textContent.trim()).toBe("The Palace"); expect(rooms[3].textContent.trim()).toBe("The Palace");
expect(rooms[4].textContent.trim()).toBe("Macbeth's Castle"); expect(rooms[4].textContent.trim()).toBe("Macbeth's Castle");
rooms[4].querySelector('.open-room').click(); rooms[4].querySelector('.open-room').click();
return test_utils.waitUntil(() => _converse.chatboxes.length > 1); await test_utils.waitUntil(() => _converse.chatboxes.length > 1);
}).then(() => { expect(sizzle('.chatroom', _converse.el).filter(u.isVisible).length).toBe(1); // There should now be an open chatroom
expect(sizzle('.chatroom', _converse.el).filter(u.isVisible).length).toBe(1); // There should now be an open chatroom var view = _converse.chatboxviews.get('inverness@chat.shakespeare.lit');
var view = _converse.chatboxviews.get('inverness@chat.shakespeare.lit'); expect(view.el.querySelector('.chat-head-chatroom').textContent.trim()).toBe("Macbeth's Castle");
expect(view.el.querySelector('.chat-head-chatroom').textContent.trim()).toBe("Macbeth's Castle"); done();
done();
}).catch(_.partial(console.error, _));
})); }));
it("shows the number of unread mentions received", it("shows the number of unread mentions received",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -367,16 +367,14 @@ converse.plugins.add('converse-muc-views', { ...@@ -367,16 +367,14 @@ converse.plugins.add('converse-muc-views', {
updateRoomsList () { updateRoomsList () {
/* Send an IQ stanza to the server asking for all groupchats /* Send an IQ stanza to the server asking for all groupchats
*/ */
_converse.connection.sendIQ( const iq = $iq({
$iq({ 'to': this.model.get('muc_domain'),
'to': this.model.get('muc_domain'), 'from': _converse.connection.jid,
'from': _converse.connection.jid, 'type': "get"
'type': "get" }).c("query", {xmlns: Strophe.NS.DISCO_ITEMS});
}).c("query", {xmlns: Strophe.NS.DISCO_ITEMS}), _converse.api.sendIQ(iq)
this.onRoomsFound.bind(this), .then(iq => this.onRoomsFound(iq))
this.informNoRoomsFound.bind(this), .catch(iq => this.informNoRoomsFound())
5000
);
}, },
showRooms (ev) { showRooms (ev) {
...@@ -805,7 +803,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -805,7 +803,7 @@ converse.plugins.add('converse-muc-views', {
const item = $build("item", {nick, role}); const item = $build("item", {nick, role});
const iq = $iq({to: groupchat, type: "set"}).c("query", {xmlns: Strophe.NS.MUC_ADMIN}).cnode(item.node); const iq = $iq({to: groupchat, type: "set"}).c("query", {xmlns: Strophe.NS.MUC_ADMIN}).cnode(item.node);
if (reason !== null) { iq.c("reason", reason); } if (reason !== null) { iq.c("reason", reason); }
return _converse.connection.sendIQ(iq, onSuccess, onError); return _converse.api.sendIQ(iq).then(onSuccess).catch(onError);
}, },
verifyRoles (roles) { verifyRoles (roles) {
......
...@@ -1651,9 +1651,9 @@ _converse.api = { ...@@ -1651,9 +1651,9 @@ _converse.api = {
* @returns {Promise} A promise which resolves when we receive a `result` stanza * @returns {Promise} A promise which resolves when we receive a `result` stanza
* or is rejected when we receive an `error` stanza. * or is rejected when we receive an `error` stanza.
*/ */
'sendIQ' (stanza) { 'sendIQ' (stanza, timeout) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
_converse.connection.sendIQ(stanza, resolve, reject, _converse.IQ_TIMEOUT); _converse.connection.sendIQ(stanza, resolve, reject, timeout || _converse.IQ_TIMEOUT);
_converse.emit('send', stanza); _converse.emit('send', stanza);
}); });
} }
......
...@@ -99,9 +99,8 @@ function queryForArchivedMessages (_converse, options, callback, errback) { ...@@ -99,9 +99,8 @@ function queryForArchivedMessages (_converse, options, callback, errback) {
return true; return true;
}, Strophe.NS.MAM); }, Strophe.NS.MAM);
_converse.connection.sendIQ( _converse.api.sendIQ(stanza, _converse.message_archiving_timeout)
stanza, .then(iq => {
function (iq) {
_converse.connection.deleteHandler(message_handler); _converse.connection.deleteHandler(message_handler);
if (_.isFunction(callback)) { if (_.isFunction(callback)) {
const set = iq.querySelector('set'); const set = iq.querySelector('set');
...@@ -112,13 +111,13 @@ function queryForArchivedMessages (_converse, options, callback, errback) { ...@@ -112,13 +111,13 @@ function queryForArchivedMessages (_converse, options, callback, errback) {
} }
callback(messages, rsm); callback(messages, rsm);
} }
}, }).catch(e => {
function () {
_converse.connection.deleteHandler(message_handler); _converse.connection.deleteHandler(message_handler);
if (_.isFunction(errback)) { errback.apply(this, arguments); } if (_.isFunction(errback)) {
}, errback.apply(this, arguments);
_converse.message_archiving_timeout }
); return;
});
} }
...@@ -333,7 +332,7 @@ converse.plugins.add('converse-mam', { ...@@ -333,7 +332,7 @@ converse.plugins.add('converse-mam', {
message_archiving_timeout: 8000, // Time (in milliseconds) to wait before aborting MAM request message_archiving_timeout: 8000, // Time (in milliseconds) to wait before aborting MAM request
}); });
_converse.onMAMError = function (model, iq) { _converse.onMAMError = function (iq) {
if (iq.querySelectorAll('feature-not-implemented').length) { if (iq.querySelectorAll('feature-not-implemented').length) {
_converse.log( _converse.log(
"Message Archive Management (XEP-0313) not supported by this server", "Message Archive Management (XEP-0313) not supported by this server",
...@@ -365,17 +364,14 @@ converse.plugins.add('converse-mam', { ...@@ -365,17 +364,14 @@ converse.plugins.add('converse-mam', {
'xmlns':Strophe.NS.MAM, 'xmlns':Strophe.NS.MAM,
'default':_converse.message_archiving 'default':_converse.message_archiving
}); });
_.each(preference.children, function (child) { _.each(preference.children, child => stanza.cnode(child).up());
stanza.cnode(child).up();
}); // XXX: Strictly speaking, the server should respond with the updated prefs
_converse.connection.sendIQ(stanza, _.partial(function (feature, iq) { // (see example 18: https://xmpp.org/extensions/xep-0313.html#config)
// XXX: Strictly speaking, the server should respond with the updated prefs // but Prosody doesn't do this, so we don't rely on it.
// (see example 18: https://xmpp.org/extensions/xep-0313.html#config) _converse.api.sendIQ(stanza)
// but Prosody doesn't do this, so we don't rely on it. .then(() => feature.save({'preferences': {'default':_converse.message_archiving}}))
feature.save({'preferences': {'default':_converse.message_archiving}}); .catch(_converse.onMAMError);
}, feature),
_converse.onMAMError
);
} else { } else {
feature.save({'preferences': {'default':_converse.message_archiving}}); feature.save({'preferences': {'default':_converse.message_archiving}});
} }
...@@ -388,11 +384,9 @@ converse.plugins.add('converse-mam', { ...@@ -388,11 +384,9 @@ converse.plugins.add('converse-mam', {
prefs['default'] !== _converse.message_archiving && // eslint-disable-line dot-notation prefs['default'] !== _converse.message_archiving && // eslint-disable-line dot-notation
!_.isUndefined(_converse.message_archiving) ) { !_.isUndefined(_converse.message_archiving) ) {
// Ask the server for archiving preferences // Ask the server for archiving preferences
_converse.connection.sendIQ( _converse.api.sendIQ($iq({'type': 'get'}).c('prefs', {'xmlns': Strophe.NS.MAM}))
$iq({'type': 'get'}).c('prefs', {'xmlns': Strophe.NS.MAM}), .then(_.partial(_converse.onMAMPreferences, feature))
_.partial(_converse.onMAMPreferences, feature), .catch(_converse.onMAMError);
_.partial(_converse.onMAMError, feature)
);
} }
}); });
......
...@@ -620,16 +620,10 @@ converse.plugins.add('converse-muc', { ...@@ -620,16 +620,10 @@ converse.plugins.add('converse-muc', {
* Returns a promise which resolves once the response IQ * Returns a promise which resolves once the response IQ
* has been received. * has been received.
*/ */
return new Promise((resolve, reject) => { return _converse.api.sendIQ(
_converse.connection.sendIQ( $iq({'to': this.get('jid'), 'type': "get"})
$iq({ .c("query", {xmlns: Strophe.NS.MUC_OWNER})
'to': this.get('jid'), );
'type': "get"
}).c("query", {xmlns: Strophe.NS.MUC_OWNER}),
resolve,
reject
);
});
}, },
sendConfiguration (config, callback, errback) { sendConfiguration (config, callback, errback) {
...@@ -652,7 +646,7 @@ converse.plugins.add('converse-muc', { ...@@ -652,7 +646,7 @@ converse.plugins.add('converse-muc', {
_.each(config || [], function (node) { iq.cnode(node).up(); }); _.each(config || [], function (node) { iq.cnode(node).up(); });
callback = _.isUndefined(callback) ? _.noop : _.partial(callback, iq.nodeTree); callback = _.isUndefined(callback) ? _.noop : _.partial(callback, iq.nodeTree);
errback = _.isUndefined(errback) ? _.noop : _.partial(errback, iq.nodeTree); errback = _.isUndefined(errback) ? _.noop : _.partial(errback, iq.nodeTree);
return _converse.connection.sendIQ(iq, callback, errback); return _converse.api.sendIQ(iq).then(callback).catch(errback);
}, },
saveAffiliationAndRole (pres) { saveAffiliationAndRole (pres) {
...@@ -685,19 +679,17 @@ converse.plugins.add('converse-muc', { ...@@ -685,19 +679,17 @@ converse.plugins.add('converse-muc', {
* (Object) member: Map containing the member's jid and * (Object) member: Map containing the member's jid and
* optionally a reason and affiliation. * optionally a reason and affiliation.
*/ */
return new Promise((resolve, reject) => { const iq = $iq({to: this.get('jid'), type: "set"})
const iq = $iq({to: this.get('jid'), type: "set"}) .c("query", {xmlns: Strophe.NS.MUC_ADMIN})
.c("query", {xmlns: Strophe.NS.MUC_ADMIN}) .c("item", {
.c("item", { 'affiliation': member.affiliation || affiliation,
'affiliation': member.affiliation || affiliation, 'nick': member.nick,
'nick': member.nick, 'jid': member.jid
'jid': member.jid });
}); if (!_.isUndefined(member.reason)) {
if (!_.isUndefined(member.reason)) { iq.c("reason", member.reason);
iq.c("reason", member.reason); }
} return _converse.api.sendIQ(iq);
_converse.connection.sendIQ(iq, resolve, reject);
});
}, },
setAffiliations (members) { setAffiliations (members) {
......
...@@ -329,7 +329,7 @@ converse.plugins.add('converse-roster', { ...@@ -329,7 +329,7 @@ converse.plugins.add('converse-roster', {
const iq = $iq({type: 'set'}) const iq = $iq({type: 'set'})
.c('query', {xmlns: Strophe.NS.ROSTER}) .c('query', {xmlns: Strophe.NS.ROSTER})
.c('item', {jid: this.get('jid'), subscription: "remove"}); .c('item', {jid: this.get('jid'), subscription: "remove"});
_converse.connection.sendIQ(iq, callback, errback); _converse.api.sendIQ(iq).then(callback).catch(errback);
return this; return this;
} }
}); });
...@@ -451,7 +451,7 @@ converse.plugins.add('converse-roster', { ...@@ -451,7 +451,7 @@ converse.plugins.add('converse-roster', {
this.addContactToRoster(jid, name, groups, attributes).then(handler, handler); this.addContactToRoster(jid, name, groups, attributes).then(handler, handler);
}, },
sendContactAddIQ (jid, name, groups, callback, errback) { sendContactAddIQ (jid, name, groups) {
/* Send an IQ stanza to the XMPP server to add a new roster contact. /* Send an IQ stanza to the XMPP server to add a new roster contact.
* *
* Parameters: * Parameters:
...@@ -462,14 +462,14 @@ converse.plugins.add('converse-roster', { ...@@ -462,14 +462,14 @@ converse.plugins.add('converse-roster', {
* (Function) errback - A function to call if an error occurred * (Function) errback - A function to call if an error occurred
*/ */
name = _.isEmpty(name)? jid: name; name = _.isEmpty(name)? jid: name;
const iq = $iq({type: 'set'}) const iq = $iq({'type': 'set'})
.c('query', {xmlns: Strophe.NS.ROSTER}) .c('query', {'xmlns': Strophe.NS.ROSTER})
.c('item', { jid, name }); .c('item', { jid, name });
_.each(groups, function (group) { iq.c('group').t(group).up(); }); _.each(groups, group => iq.c('group').t(group).up());
_converse.connection.sendIQ(iq, callback, errback); _converse.api.sendIQ(iq);
}, },
addContactToRoster (jid, name, groups, attributes) { async addContactToRoster (jid, name, groups, attributes) {
/* Adds a RosterContact instance to _converse.roster and /* Adds a RosterContact instance to _converse.roster and
* registers the contact on the XMPP server. * registers the contact on the XMPP server.
* Returns a promise which is resolved once the XMPP server has * Returns a promise which is resolved once the XMPP server has
...@@ -481,27 +481,22 @@ converse.plugins.add('converse-roster', { ...@@ -481,27 +481,22 @@ converse.plugins.add('converse-roster', {
* (Array of Strings) groups - Any roster groups the user might belong to * (Array of Strings) groups - Any roster groups the user might belong to
* (Object) attributes - Any additional attributes to be stored on the user's model. * (Object) attributes - Any additional attributes to be stored on the user's model.
*/ */
return new Promise((resolve, reject) => { groups = groups || [];
groups = groups || []; try {
this.sendContactAddIQ(jid, name, groups, await this.sendContactAddIQ(jid, name, groups);
() => { } catch (e) {
const contact = this.create(_.assignIn({ _converse.log(e, Strophe.LogLevel.ERROR);
'ask': undefined, alert(__('Sorry, there was an error while trying to add %1$s as a contact.', name));
'nickname': name, return e;
groups, }
jid, return this.create(_.assignIn({
'requesting': false, 'ask': undefined,
'subscription': 'none' 'nickname': name,
}, attributes), {sort: false}); groups,
resolve(contact); jid,
}, 'requesting': false,
function (err) { 'subscription': 'none'
alert(__('Sorry, there was an error while trying to add %1$s as a contact.', name)); }, attributes), {'sort': false});
_converse.log(err, Strophe.LogLevel.ERROR);
resolve(err);
}
);
});
}, },
subscribeBack (bare_jid, presence) { subscribeBack (bare_jid, presence) {
...@@ -570,24 +565,26 @@ converse.plugins.add('converse-roster', { ...@@ -570,24 +565,26 @@ converse.plugins.add('converse-roster', {
return _converse.api.disco.stream.getFeature('ver', 'urn:xmpp:features:rosterver') && this.data.get('version'); return _converse.api.disco.stream.getFeature('ver', 'urn:xmpp:features:rosterver') && this.data.get('version');
}, },
fetchFromServer () { async fetchFromServer () {
/* Fetch the roster from the XMPP server */ /* Fetch the roster from the XMPP server */
return new Promise((resolve, reject) => { const stanza = $iq({
const iq = $iq({ 'type': 'get',
'type': 'get', 'id': _converse.connection.getUniqueId('roster')
'id': _converse.connection.getUniqueId('roster') }).c('query', {xmlns: Strophe.NS.ROSTER});
}).c('query', {xmlns: Strophe.NS.ROSTER}); if (this.rosterVersioningSupported()) {
if (this.rosterVersioningSupported()) { stanza.attrs({'ver': this.data.get('version')});
iq.attrs({'ver': this.data.get('version')}); }
} let iq;
const callback = _.flow(this.onReceivedFromServer.bind(this), resolve); try {
const errback = function (iq) { iq = await _converse.api.sendIQ(stanza);
const errmsg = "Error while trying to fetch roster from the server"; } catch (e) {
_converse.log(errmsg, Strophe.LogLevel.ERROR); _converse.log(e, Strophe.LogLevel.ERROR);
reject(new Error(errmsg)); return _converse.log(
} "Error while trying to fetch roster from the server",
return _converse.connection.sendIQ(iq, callback, errback); Strophe.LogLevel.ERROR
}); );
}
return this.onReceivedFromServer(iq);
}, },
onReceivedFromServer (iq) { onReceivedFromServer (iq) {
...@@ -646,7 +643,7 @@ converse.plugins.add('converse-roster', { ...@@ -646,7 +643,7 @@ converse.plugins.add('converse-roster', {
createRequestingContact (presence) { createRequestingContact (presence) {
const bare_jid = Strophe.getBareJidFromJid(presence.getAttribute('from')), const bare_jid = Strophe.getBareJidFromJid(presence.getAttribute('from')),
nickname = _.get(sizzle(`nick[xmlns="${Strophe.NS.NICK}"]`, presence).pop(), 'textContent', null); nickname = _.get(sizzle(`nick[xmlns="${Strophe.NS.NICK}"]`, presence).pop(), 'textContent', null);
const user_data = { const user_data = {
'jid': bare_jid, 'jid': bare_jid,
'subscription': 'none', 'subscription': 'none',
......
...@@ -56,7 +56,7 @@ converse.plugins.add('converse-vcard', { ...@@ -56,7 +56,7 @@ converse.plugins.add('converse-vcard', {
}); });
function onVCardData (jid, iq, callback) { async function onVCardData (jid, iq) {
const vcard = iq.querySelector('vCard'); const vcard = iq.querySelector('vCard');
let result = {}; let result = {};
if (!_.isNull(vcard)) { if (!_.isNull(vcard)) {
...@@ -75,24 +75,10 @@ converse.plugins.add('converse-vcard', { ...@@ -75,24 +75,10 @@ converse.plugins.add('converse-vcard', {
} }
if (result.image) { if (result.image) {
const buffer = u.base64ToArrayBuffer(result['image']); const buffer = u.base64ToArrayBuffer(result['image']);
crypto.subtle.digest('SHA-1', buffer) const ab = await crypto.subtle.digest('SHA-1', buffer);
.then(ab => { result['image_hash'] = u.arrayBufferToHex(ab);
result['image_hash'] = u.arrayBufferToHex(ab);
if (callback) callback(result);
});
} else {
if (callback) callback(result);
}
}
function onVCardError (jid, iq, errback) {
if (errback) {
errback({
'stanza': iq,
'jid': jid,
'vcard_error': moment().format()
});
} }
return result;
} }
function createStanza (type, jid, vcard_el) { function createStanza (type, jid, vcard_el) {
...@@ -113,7 +99,7 @@ converse.plugins.add('converse-vcard', { ...@@ -113,7 +99,7 @@ converse.plugins.add('converse-vcard', {
return _converse.api.sendIQ(createStanza("set", jid, vcard_el)); return _converse.api.sendIQ(createStanza("set", jid, vcard_el));
} }
function getVCard (_converse, jid) { async function getVCard (_converse, jid) {
/* Request the VCard of another user. Returns a promise. /* Request the VCard of another user. Returns a promise.
* *
* Parameters: * Parameters:
...@@ -121,14 +107,17 @@ converse.plugins.add('converse-vcard', { ...@@ -121,14 +107,17 @@ converse.plugins.add('converse-vcard', {
* is being requested. * is being requested.
*/ */
const to = Strophe.getBareJidFromJid(jid) === _converse.bare_jid ? null : jid; const to = Strophe.getBareJidFromJid(jid) === _converse.bare_jid ? null : jid;
return new Promise((resolve, reject) => { let iq;
_converse.connection.sendIQ( try {
createStanza("get", to), iq = await _converse.api.sendIQ(createStanza("get", to))
_.partial(onVCardData, jid, _, resolve), } catch (iq) {
_.partial(onVCardError, jid, _, resolve), return {
_converse.IQ_TIMEOUT 'stanza': iq,
); 'jid': jid,
}); 'vcard_error': moment().format()
}
}
return onVCardData(jid, iq);
} }
/* Event handlers */ /* Event handlers */
......
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