|
@@ -293,6 +293,42 @@ converse.plugins.add('converse-disco', {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ const plugin = this;
|
|
|
|
+ plugin._identities = [];
|
|
|
|
+ plugin._features = [];
|
|
|
|
+
|
|
|
|
+ function onDiscoInfoRequest (stanza) {
|
|
|
|
+ const node = stanza.getElementsByTagName('query')[0].getAttribute('node');
|
|
|
|
+ const attrs = {xmlns: Strophe.NS.DISCO_INFO};
|
|
|
|
+ if (node) { attrs.node = node; }
|
|
|
|
+
|
|
|
|
+ const iqresult = $iq({'type': 'result', 'id': stanza.getAttribute('id')});
|
|
|
|
+ const from = stanza.getAttribute('from');
|
|
|
|
+ if (from !== null) {
|
|
|
|
+ iqresult.attrs({'to': from});
|
|
|
|
+ }
|
|
|
|
+ iqresult.c('query', attrs);
|
|
|
|
+ _.each(plugin._identities, (identity) => {
|
|
|
|
+ const attrs = {
|
|
|
|
+ 'category': identity.category,
|
|
|
|
+ 'type': identity.type
|
|
|
|
+ };
|
|
|
|
+ if (identity.name) {
|
|
|
|
+ attrs.name = identity.name;
|
|
|
|
+ }
|
|
|
|
+ if (identity.lang) {
|
|
|
|
+ attrs['xml:lang'] = identity.lang;
|
|
|
|
+ }
|
|
|
|
+ iqresult.c('identity', attrs).up();
|
|
|
|
+ });
|
|
|
|
+ _.each(plugin._features, (feature) => {
|
|
|
|
+ iqresult.c('feature', {'var': feature}).up();
|
|
|
|
+ });
|
|
|
|
+ _converse.api.send(iqresult.tree());
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
async function initializeDisco () {
|
|
async function initializeDisco () {
|
|
addClientFeatures();
|
|
addClientFeatures();
|
|
_converse.connection.addHandler(onDiscoInfoRequest, Strophe.NS.DISCO_INFO, 'iq', 'get', null, null);
|
|
_converse.connection.addHandler(onDiscoInfoRequest, Strophe.NS.DISCO_INFO, 'iq', 'get', null, null);
|
|
@@ -318,6 +354,8 @@ converse.plugins.add('converse-disco', {
|
|
_converse.api.trigger('discoInitialized');
|
|
_converse.api.trigger('discoInitialized');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /******************** Event Handlers ********************/
|
|
|
|
+
|
|
_converse.api.listen.on('userSessionInitialized', initStreamFeatures);
|
|
_converse.api.listen.on('userSessionInitialized', initStreamFeatures);
|
|
_converse.api.listen.on('beforeResourceBinding', initStreamFeatures);
|
|
_converse.api.listen.on('beforeResourceBinding', initStreamFeatures);
|
|
|
|
|
|
@@ -334,46 +372,13 @@ converse.plugins.add('converse-disco', {
|
|
_converse.disco_entities.browserStorage._clear();
|
|
_converse.disco_entities.browserStorage._clear();
|
|
}
|
|
}
|
|
if (_converse.stream_features) {
|
|
if (_converse.stream_features) {
|
|
- _converse.stream_features.reset();
|
|
|
|
|
|
+ Array.from(_converse.stream_features.models).forEach(f => f.destroy());
|
|
_converse.stream_features.browserStorage._clear();
|
|
_converse.stream_features.browserStorage._clear();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- const plugin = this;
|
|
|
|
- plugin._identities = [];
|
|
|
|
- plugin._features = [];
|
|
|
|
-
|
|
|
|
- function onDiscoInfoRequest (stanza) {
|
|
|
|
- const node = stanza.getElementsByTagName('query')[0].getAttribute('node');
|
|
|
|
- const attrs = {xmlns: Strophe.NS.DISCO_INFO};
|
|
|
|
- if (node) { attrs.node = node; }
|
|
|
|
-
|
|
|
|
- const iqresult = $iq({'type': 'result', 'id': stanza.getAttribute('id')});
|
|
|
|
- const from = stanza.getAttribute('from');
|
|
|
|
- if (from !== null) {
|
|
|
|
- iqresult.attrs({'to': from});
|
|
|
|
- }
|
|
|
|
- iqresult.c('query', attrs);
|
|
|
|
- _.each(plugin._identities, (identity) => {
|
|
|
|
- const attrs = {
|
|
|
|
- 'category': identity.category,
|
|
|
|
- 'type': identity.type
|
|
|
|
- };
|
|
|
|
- if (identity.name) {
|
|
|
|
- attrs.name = identity.name;
|
|
|
|
- }
|
|
|
|
- if (identity.lang) {
|
|
|
|
- attrs['xml:lang'] = identity.lang;
|
|
|
|
- }
|
|
|
|
- iqresult.c('identity', attrs).up();
|
|
|
|
- });
|
|
|
|
- _.each(plugin._features, (feature) => {
|
|
|
|
- iqresult.c('feature', {'var': feature}).up();
|
|
|
|
- });
|
|
|
|
- _converse.api.send(iqresult.tree());
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ /************************ API ************************/
|
|
|
|
|
|
Object.assign(_converse.api, {
|
|
Object.assign(_converse.api, {
|
|
/**
|
|
/**
|