Parse and save jabber❌data formdata from a disco#info result
This commit is contained in:
parent
c01e9f8265
commit
076ace3fad
@ -162,6 +162,7 @@
|
|||||||
function (result) {
|
function (result) {
|
||||||
expect(result.length).toBe(1);
|
expect(result.length).toBe(1);
|
||||||
expect(result[0].get('jid')).toBe('upload.localhost');
|
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();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -37,6 +37,11 @@
|
|||||||
initialize () {
|
initialize () {
|
||||||
this.waitUntilFeaturesDiscovered = utils.getResolveablePromise();
|
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 = new Backbone.Collection();
|
||||||
this.features.browserStorage = new Backbone.BrowserStorage[_converse.storage](
|
this.features.browserStorage = new Backbone.BrowserStorage[_converse.storage](
|
||||||
b64_sha1(`converse.features-${this.get('jid')}`)
|
b64_sha1(`converse.features-${this.get('jid')}`)
|
||||||
@ -155,6 +160,18 @@
|
|||||||
'name': identity.getAttribute('name')
|
'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+'"]')) {
|
if (stanza.querySelector('feature[var="'+Strophe.NS.DISCO_ITEMS+'"]')) {
|
||||||
this.queryForItems();
|
this.queryForItems();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user