Commit 076ace3f authored by JC Brand's avatar JC Brand

Parse and save jabber:x:data formdata from a disco#info result

parent c01e9f82
......@@ -162,6 +162,7 @@
function (result) {
expect(result.length).toBe(1);
expect(result[0].get('jid')).toBe('upload.localhost');
expect(result[0].dataforms.where({'FORM_TYPE': {value: "urn:xmpp:http:upload:0", type: "hidden"}}).length).toBe(1);
done();
}
);
......
......@@ -37,6 +37,11 @@
initialize () {
this.waitUntilFeaturesDiscovered = utils.getResolveablePromise();
this.dataforms = new Backbone.Collection();
this.dataforms.browserStorage = new Backbone.BrowserStorage[_converse.storage](
b64_sha1(`converse.dataforms-{this.get('jid')}`)
);
this.features = new Backbone.Collection();
this.features.browserStorage = new Backbone.BrowserStorage[_converse.storage](
b64_sha1(`converse.features-${this.get('jid')}`)
......@@ -155,6 +160,18 @@
'name': identity.getAttribute('name')
});
});
_.each(sizzle('x[type="result"][xmlns="jabber:x:data"]', stanza), (form) => {
const data = {};
_.each(form.querySelectorAll('field'), (field) => {
data[field.getAttribute('var')] = {
'value': _.get(field.querySelector('value'), 'textContent'),
'type': field.getAttribute('type')
};
});
this.dataforms.create(data);
});
if (stanza.querySelector('feature[var="'+Strophe.NS.DISCO_ITEMS+'"]')) {
this.queryForItems();
}
......
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