|
@@ -41350,7 +41350,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|
|
onBookmarksReceivedError(deferred, iq) {
|
|
|
window.sessionStorage.setItem(this.fetched_flag, true);
|
|
|
|
|
|
- _converse.log('Error while fetching bookmarks', Strophe.LogLevel.WARN);
|
|
|
+ _converse.log('Error while fetching bookmarks', Strophe.LogLevel.ERROR);
|
|
|
|
|
|
_converse.log(iq.outerHTML, Strophe.LogLevel.DEBUG);
|
|
|
|
|
@@ -41572,8 +41572,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|
|
if (_converse.allow_public_bookmarks) {
|
|
|
return !!identity;
|
|
|
} else {
|
|
|
- const supported = await _converse.api.disco.supports(Strophe.NS.PUBSUB + '#publish-options', _converse.bare_jid);
|
|
|
- return !!supported.length;
|
|
|
+ return _converse.api.disco.supports(Strophe.NS.PUBSUB + '#publish-options', _converse.bare_jid);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -42354,9 +42353,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
|
|
|
},
|
|
|
|
|
|
async addFileUploadButton(options) {
|
|
|
- const result = await _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain);
|
|
|
-
|
|
|
- if (result.length) {
|
|
|
+ if (await _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain)) {
|
|
|
this.el.querySelector('.chat-toolbar').insertAdjacentHTML('beforeend', templates_toolbar_fileupload_html__WEBPACK_IMPORTED_MODULE_19___default()({
|
|
|
'tooltip_upload_file': __('Choose a file to send')
|
|
|
}));
|
|
@@ -42378,9 +42375,10 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const results = await Promise.all(this.model.presence.resources.map(res => _converse.api.disco.supports(Strophe.NS.SPOILER, `${contact_jid}/${res.get('name')}`)));
|
|
|
+ const results = await Promise.all(this.model.presence.resources.map(r => _converse.api.disco.supports(Strophe.NS.SPOILER, `${contact_jid}/${r.get('name')}`)));
|
|
|
+ const all_resources_support_spolers = results.reduce((acc, val) => acc && val, true);
|
|
|
|
|
|
- if (_.filter(results, 'length').length) {
|
|
|
+ if (all_resources_support_spolers) {
|
|
|
const html = templates_spoiler_button_html__WEBPACK_IMPORTED_MODULE_16___default()(this.model.toJSON());
|
|
|
|
|
|
if (_converse.visible_toolbar_buttons.emoji) {
|
|
@@ -44972,8 +44970,8 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const _converse = this.__super__._converse,
|
|
|
- most_recent_msg = u.getMostRecentMessage(this.model);
|
|
|
+ const _converse = this.__super__._converse;
|
|
|
+ const most_recent_msg = u.getMostRecentMessage(this.model);
|
|
|
|
|
|
if (_.isNil(most_recent_msg)) {
|
|
|
this.fetchArchivedMessages();
|
|
@@ -45037,9 +45035,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|
|
message_handler = _converse.chatboxes.onMessage.bind(_converse.chatboxes);
|
|
|
}
|
|
|
|
|
|
- const supported = await _converse.api.disco.supports(Strophe.NS.MAM, mam_jid);
|
|
|
-
|
|
|
- if (!supported.length) {
|
|
|
+ if (!(await _converse.api.disco.supports(Strophe.NS.MAM, mam_jid))) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -51046,9 +51042,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const result = await _converse.api.disco.supports(Strophe.NS.PUSH, domain || _converse.bare_jid);
|
|
|
-
|
|
|
- if (!result.length) {
|
|
|
+ if (!(await _converse.api.disco.supports(Strophe.NS.PUSH, domain || _converse.bare_jid))) {
|
|
|
return _converse.log(`Not disabling push app server "${push_app_server.jid}", no disco support from your server.`, Strophe.LogLevel.WARN);
|
|
|
}
|
|
|
|
|
@@ -51093,7 +51087,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|
|
|
|
|
const result = await Promise.all([_converse.api.disco.supports(Strophe.NS.PUSH, push_app_server.jid), _converse.api.disco.supports(Strophe.NS.PUSH, domain)]);
|
|
|
|
|
|
- if (!result[0].length && !result[1].length) {
|
|
|
+ if (!result[0] && !result[1]) {
|
|
|
return _converse.log(`Not enabling push app server "${push_app_server.jid}", no disco support from your server.`, Strophe.LogLevel.WARN);
|
|
|
}
|
|
|
|
|
@@ -55346,9 +55340,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
|
|
|
}
|
|
|
|
|
|
const by_jid = stanza_id.getAttribute('by');
|
|
|
- const result = await _converse.api.disco.supports(Strophe.NS.SID, by_jid);
|
|
|
|
|
|
- if (!result.length) {
|
|
|
+ if (!(await _converse.api.disco.supports(Strophe.NS.SID, by_jid))) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -55634,8 +55627,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
|
|
|
},
|
|
|
|
|
|
async sendFiles(files) {
|
|
|
- const result = await _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain),
|
|
|
- item = result.pop();
|
|
|
+ const result = await _converse.api.disco.features.get(Strophe.NS.HTTPUPLOAD, _converse.domain);
|
|
|
+ const item = result.pop();
|
|
|
|
|
|
if (!item) {
|
|
|
this.messages.create({
|
|
@@ -59057,6 +59050,45 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-dis
|
|
|
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * @namespace _converse.api.disco.features
|
|
|
+ * @memberOf _converse.api.disco
|
|
|
+ */
|
|
|
+ 'features': {
|
|
|
+ /**
|
|
|
+ * Return a given feature of a disco entity
|
|
|
+ *
|
|
|
+ * @method _converse.api.disco.features.get
|
|
|
+ * @param {string} feature The feature that might be
|
|
|
+ * supported. In the XML stanza, this is the `var`
|
|
|
+ * attribute of the `<feature>` element. For
|
|
|
+ * example: `http://jabber.org/protocol/muc`
|
|
|
+ * @param {string} jid The JID of the entity
|
|
|
+ * (and its associated items) which should be queried
|
|
|
+ * @returns {promise} A promise which resolves with a list containing
|
|
|
+ * _converse.Entity instances representing the entity
|
|
|
+ * itself or those items associated with the entity if
|
|
|
+ * they support the given feature.
|
|
|
+ * @example
|
|
|
+ * _converse.api.disco.features.get(Strophe.NS.MAM, _converse.bare_jid);
|
|
|
+ */
|
|
|
+ async 'get'(feature, jid) {
|
|
|
+ if (_.isNil(jid)) {
|
|
|
+ throw new TypeError('You need to provide an entity JID');
|
|
|
+ }
|
|
|
+
|
|
|
+ await _converse.api.waitUntil('discoInitialized');
|
|
|
+ let entity = await _converse.api.disco.entities.get(jid, true);
|
|
|
+ entity = await entity.waitUntilFeaturesDiscovered;
|
|
|
+
|
|
|
+ const promises = _.concat(entity.items.map(item => item.hasFeature(feature)), entity.hasFeature(feature));
|
|
|
+
|
|
|
+ const result = await Promise.all(promises);
|
|
|
+ return f.filter(f.isObject, result);
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* Used to determine whether an entity supports a given feature.
|
|
|
*
|
|
@@ -59067,40 +59099,17 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-dis
|
|
|
* example: `http://jabber.org/protocol/muc`
|
|
|
* @param {string} jid The JID of the entity
|
|
|
* (and its associated items) which should be queried
|
|
|
- * @returns {promise} A promise which resolves with a list containing
|
|
|
- * _converse.Entity instances representing the entity
|
|
|
- * itself or those items associated with the entity if
|
|
|
- * they support the given feature.
|
|
|
- *
|
|
|
+ * @returns {promise} A promise which resolves with `true` or `false`.
|
|
|
* @example
|
|
|
- * _converse.api.disco.supports(Strophe.NS.MAM, _converse.bare_jid)
|
|
|
- * .then(value => {
|
|
|
- * // `value` is a map with two keys, `supported` and `feature`.
|
|
|
- * if (value.supported) {
|
|
|
- * // The feature is supported
|
|
|
- * } else {
|
|
|
- * // The feature is not supported
|
|
|
- * }
|
|
|
- * }).catch(() => {
|
|
|
- * _converse.log(
|
|
|
- * "Error or timeout while checking for feature support",
|
|
|
- * Strophe.LogLevel.ERROR
|
|
|
- * );
|
|
|
- * });
|
|
|
+ * if (await _converse.api.disco.supports(Strophe.NS.MAM, _converse.bare_jid)) {
|
|
|
+ * // The feature is supported
|
|
|
+ * } else {
|
|
|
+ * // The feature is not supported
|
|
|
+ * }
|
|
|
*/
|
|
|
async 'supports'(feature, jid) {
|
|
|
- if (_.isNil(jid)) {
|
|
|
- throw new TypeError('api.disco.supports: You need to provide an entity JID');
|
|
|
- }
|
|
|
-
|
|
|
- await _converse.api.waitUntil('discoInitialized');
|
|
|
- let entity = await _converse.api.disco.entities.get(jid, true);
|
|
|
- entity = await entity.waitUntilFeaturesDiscovered;
|
|
|
-
|
|
|
- const promises = _.concat(entity.items.map(item => item.hasFeature(feature)), entity.hasFeature(feature));
|
|
|
-
|
|
|
- const result = await Promise.all(promises);
|
|
|
- return f.filter(f.isObject, result);
|
|
|
+ const features = await _converse.api.disco.features.get(feature, jid);
|
|
|
+ return features.length > 0;
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -59271,7 +59280,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-mam
|
|
|
const by_jid = stanza.getAttribute('from') || this.get('jid');
|
|
|
const supported = await _converse.api.disco.supports(Strophe.NS.MAM, by_jid);
|
|
|
|
|
|
- if (!supported.length) {
|
|
|
+ if (!supported) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -59594,7 +59603,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-mam
|
|
|
const jid = attrs.to || _converse.bare_jid;
|
|
|
const supported = await _converse.api.disco.supports(Strophe.NS.MAM, jid);
|
|
|
|
|
|
- if (!supported.length) {
|
|
|
+ if (!supported) {
|
|
|
_converse.log(`Did not fetch MAM archive for ${jid} because it doesn't support ${Strophe.NS.MAM}`);
|
|
|
|
|
|
return {
|
|
@@ -59961,9 +59970,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins.add('converse-muc
|
|
|
|
|
|
async onConnectionStatusChanged() {
|
|
|
if (this.get('connection_status') === _converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].ROOMSTATUS.ENTERED && _converse.auto_register_muc_nickname && !this.get('reserved_nick')) {
|
|
|
- const result = await _converse.api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid'));
|
|
|
-
|
|
|
- if (result.length) {
|
|
|
+ if (await _converse.api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid'))) {
|
|
|
this.registerNickname();
|
|
|
}
|
|
|
}
|
|
@@ -61825,9 +61832,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins.add('converse-pub
|
|
|
|
|
|
if (options) {
|
|
|
jid = jid || _converse.bare_jid;
|
|
|
- const result = await _converse.api.disco.supports(Strophe.NS.PUBSUB + '#publish-options', jid);
|
|
|
|
|
|
- if (result.length) {
|
|
|
+ if (await _converse.api.disco.supports(Strophe.NS.PUBSUB + '#publish-options', jid)) {
|
|
|
stanza.c('publish-options').c('x', {
|
|
|
'xmlns': Strophe.NS.XFORM,
|
|
|
'type': 'submit'
|