converse-disco: don't call onInfo on undefined

This commit is contained in:
JC Brand 2019-06-12 06:09:08 +02:00
parent bbe2a62295
commit e1ca02d94a

View File

@ -146,6 +146,7 @@ converse.plugins.add('converse-disco', {
} catch (iq) { } catch (iq) {
_converse.log(iq, Strophe.LogLevel.ERROR); _converse.log(iq, Strophe.LogLevel.ERROR);
this.waitUntilFeaturesDiscovered.resolve(this); this.waitUntilFeaturesDiscovered.resolve(this);
return;
} }
this.onInfo(stanza); this.onInfo(stanza);
}, },
@ -382,19 +383,19 @@ converse.plugins.add('converse-disco', {
* @namespace _converse.api.disco * @namespace _converse.api.disco
* @memberOf _converse.api * @memberOf _converse.api
*/ */
'disco': { disco: {
/** /**
* @namespace _converse.api.disco.stream * @namespace _converse.api.disco.stream
* @memberOf _converse.api.disco * @memberOf _converse.api.disco
*/ */
'stream': { stream: {
/** /**
* @method _converse.api.disco.stream.getFeature * @method _converse.api.disco.stream.getFeature
* @param {String} name The feature name * @param {String} name The feature name
* @param {String} xmlns The XML namespace * @param {String} xmlns The XML namespace
* @example _converse.api.disco.stream.getFeature('ver', 'urn:xmpp:features:rosterver') * @example _converse.api.disco.stream.getFeature('ver', 'urn:xmpp:features:rosterver')
*/ */
'getFeature': async function (name, xmlns) { async getFeature (name, xmlns) {
await _converse.api.waitUntil('streamFeaturesAdded'); await _converse.api.waitUntil('streamFeaturesAdded');
if (_.isNil(name) || _.isNil(xmlns)) { if (_.isNil(name) || _.isNil(xmlns)) {
throw new Error("name and xmlns need to be provided when calling disco.stream.getFeature"); throw new Error("name and xmlns need to be provided when calling disco.stream.getFeature");
@ -407,12 +408,12 @@ converse.plugins.add('converse-disco', {
* @namespace _converse.api.disco.own * @namespace _converse.api.disco.own
* @memberOf _converse.api.disco * @memberOf _converse.api.disco
*/ */
'own': { own: {
/** /**
* @namespace _converse.api.disco.own.identities * @namespace _converse.api.disco.own.identities
* @memberOf _converse.api.disco.own * @memberOf _converse.api.disco.own
*/ */
'identities': { identities: {
/** /**
* Lets you add new identities for this client (i.e. instance of Converse) * Lets you add new identities for this client (i.e. instance of Converse)
* @method _converse.api.disco.own.identities.add * @method _converse.api.disco.own.identities.add
@ -458,7 +459,7 @@ converse.plugins.add('converse-disco', {
* @namespace _converse.api.disco.own.features * @namespace _converse.api.disco.own.features
* @memberOf _converse.api.disco.own * @memberOf _converse.api.disco.own
*/ */
'features': { features: {
/** /**
* Lets you register new disco features for this client (i.e. instance of Converse) * Lets you register new disco features for this client (i.e. instance of Converse)
* @method _converse.api.disco.own.features.add * @method _converse.api.disco.own.features.add
@ -498,7 +499,7 @@ converse.plugins.add('converse-disco', {
* @param {string} [node] A specific node identifier associated with the JID * @param {string} [node] A specific node identifier associated with the JID
* @returns {promise} Promise which resolves once we have a result from the server. * @returns {promise} Promise which resolves once we have a result from the server.
*/ */
'info' (jid, node) { info (jid, node) {
const attrs = {xmlns: Strophe.NS.DISCO_INFO}; const attrs = {xmlns: Strophe.NS.DISCO_INFO};
if (node) { if (node) {
attrs.node = node; attrs.node = node;
@ -519,7 +520,7 @@ converse.plugins.add('converse-disco', {
* @param {string} [node] A specific node identifier associated with the JID * @param {string} [node] A specific node identifier associated with the JID
* @returns {promise} Promise which resolves once we have a result from the server. * @returns {promise} Promise which resolves once we have a result from the server.
*/ */
'items' (jid, node) { items (jid, node) {
const attrs = {'xmlns': Strophe.NS.DISCO_ITEMS}; const attrs = {'xmlns': Strophe.NS.DISCO_ITEMS};
if (node) { if (node) {
attrs.node = node; attrs.node = node;
@ -539,7 +540,7 @@ converse.plugins.add('converse-disco', {
* @namespace _converse.api.disco.entities * @namespace _converse.api.disco.entities
* @memberOf _converse.api.disco * @memberOf _converse.api.disco
*/ */
'entities': { entities: {
/** /**
* Get the the corresponding `DiscoEntity` instance. * Get the the corresponding `DiscoEntity` instance.
* *
@ -548,7 +549,7 @@ converse.plugins.add('converse-disco', {
* @param {boolean} [create] Whether the entity should be created if it doesn't exist. * @param {boolean} [create] Whether the entity should be created if it doesn't exist.
* @example _converse.api.disco.entities.get(jid); * @example _converse.api.disco.entities.get(jid);
*/ */
async 'get' (jid, create=false) { async get (jid, create=false) {
await _converse.api.waitUntil('discoInitialized'); await _converse.api.waitUntil('discoInitialized');
if (_.isNil(jid)) { if (_.isNil(jid)) {
return _converse.disco_entities; return _converse.disco_entities;
@ -583,7 +584,7 @@ converse.plugins.add('converse-disco', {
* @example * @example
* _converse.api.disco.features.get(Strophe.NS.MAM, _converse.bare_jid); * _converse.api.disco.features.get(Strophe.NS.MAM, _converse.bare_jid);
*/ */
async 'get' (feature, jid) { async get (feature, jid) {
if (_.isNil(jid)) { if (_.isNil(jid)) {
throw new TypeError('You need to provide an entity JID'); throw new TypeError('You need to provide an entity JID');
} }
@ -617,7 +618,7 @@ converse.plugins.add('converse-disco', {
* // The feature is not supported * // The feature is not supported
* } * }
*/ */
async 'supports' (feature, jid) { async supports (feature, jid) {
const features = await _converse.api.disco.features.get(feature, jid); const features = await _converse.api.disco.features.get(feature, jid);
return features.length > 0; return features.length > 0;
}, },
@ -632,7 +633,7 @@ converse.plugins.add('converse-disco', {
* @example * @example
* await _converse.api.disco.refreshFeatures('room@conference.example.org'); * await _converse.api.disco.refreshFeatures('room@conference.example.org');
*/ */
async 'refreshFeatures' (jid) { async refreshFeatures (jid) {
if (_.isNil(jid)) { if (_.isNil(jid)) {
throw new TypeError('api.disco.refreshFeatures: You need to provide an entity JID'); throw new TypeError('api.disco.refreshFeatures: You need to provide an entity JID');
} }
@ -655,7 +656,7 @@ converse.plugins.add('converse-disco', {
* @example * @example
* const features = await _converse.api.disco.getFeatures('room@conference.example.org'); * const features = await _converse.api.disco.getFeatures('room@conference.example.org');
*/ */
async 'getFeatures' (jid) { async getFeatures (jid) {
if (_.isNil(jid)) { if (_.isNil(jid)) {
throw new TypeError('api.disco.getFeatures: You need to provide an entity JID'); throw new TypeError('api.disco.getFeatures: You need to provide an entity JID');
} }
@ -676,7 +677,7 @@ converse.plugins.add('converse-disco', {
* @example * @example
* const fields = await _converse.api.disco.getFields('room@conference.example.org'); * const fields = await _converse.api.disco.getFields('room@conference.example.org');
*/ */
async 'getFields' (jid) { async getFields (jid) {
if (_.isNil(jid)) { if (_.isNil(jid)) {
throw new TypeError('api.disco.getFields: You need to provide an entity JID'); throw new TypeError('api.disco.getFields: You need to provide an entity JID');
} }
@ -717,7 +718,7 @@ converse.plugins.add('converse-disco', {
* } * }
* ).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); * ).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
*/ */
async 'getIdentity' (category, type, jid) { async getIdentity (category, type, jid) {
const e = await _converse.api.disco.entities.get(jid, true); const e = await _converse.api.disco.entities.get(jid, true);
return e.getIdentity(category, type); return e.getIdentity(category, type);
} }