Commit 1261a252 authored by JC Brand's avatar JC Brand

Use Strophe.RSM for result set management.

parent b77d76b3
......@@ -118,6 +118,11 @@
}
};
// Global constants
// XEP-0059 Result Set Management
var RSM_ATTRIBUTES = ['max', 'first', 'last', 'after', 'before', 'index', 'count'];
var STATUS_WEIGHTS = {
'offline': 6,
'unavailable': 5,
......@@ -6138,14 +6143,14 @@
}
});
stanza.up();
if (options.limit) {
stanza.c('set', {'xmlns':Strophe.NS.RSM}).c('max').t(options.limit).up();
}
if (options.after) {
stanza.c('after').t(options.after).up();
if (_.intersection(RSM_ATTRIBUTES, _.keys(options)).length) {
stanza.cnode(new Strophe.RSM(options).toXML());
}
}
converse.connection.sendIQ(stanza, callback, errback);
converse.connection.sendIQ(stanza, function (iq) {
var rsm = new Strophe.RSM({xml: iq.getElementsByTagName('set')[0]});
return _.bind(callback, this, arguments)(rsm);
}, errback);
}
},
'rooms': {
......
......@@ -27,17 +27,18 @@ require.config({
"jquery.browser": "components/jquery.browser/dist/jquery.browser",
"jquery.easing": "components/jquery-easing-original/index", // XXX: Only required for https://conversejs.org website
"moment": "components/momentjs/moment",
"strophe": "components/strophejs/src/wrapper",
"strophe-base64": "components/strophejs/src/base64",
"strophe-bosh": "components/strophejs/src/bosh",
"strophe-core": "components/strophejs/src/core",
"strophe": "components/strophejs/src/wrapper",
"strophe-md5": "components/strophejs/src/md5",
"strophe-polyfill": "components/strophejs/src/polyfills",
"strophe-sha1": "components/strophejs/src/sha1",
"strophe-websocket": "components/strophejs/src/websocket",
"strophe-polyfill": "components/strophejs/src/polyfills",
"strophe.disco": "components/strophejs-plugins/disco/strophe.disco",
"strophe.vcard": "src/strophe.vcard",
"strophe.ping": "src/strophe.ping",
"strophe.rsm": "components/strophejs-plugins/rsm/strophe.rsm",
"strophe.vcard": "src/strophe.vcard",
"text": 'components/requirejs-text/text',
"tpl": 'components/requirejs-tpl-jcbrand/tpl',
"typeahead": "components/typeahead.js/index",
......@@ -185,10 +186,9 @@ require.config({
'crypto.sha1': { deps: ['crypto.core'] },
'crypto.sha256': { deps: ['crypto.core'] },
'bigint': { deps: ['crypto'] },
'strophe.disco': { deps: ['strophe'] },
'strophe.ping': { deps: ['strophe'] },
'strophe.register': { deps: ['strophe'] },
'strophe.vcard': { deps: ['strophe'] },
'strophe.ping': { deps: ['strophe'] }
'strophe.vcard': { deps: ['strophe'] }
}
});
......
......@@ -161,7 +161,7 @@
Date.prototype.getTimezoneOffset = function () {
return -120;
};
converse_api.archive.query({'start': '2010-06-07T00:00:00Z', 'limit':10});
converse_api.archive.query({'start': '2010-06-07T00:00:00Z', 'max':10});
var queryid = $(sent_stanza.toString()).find('query').attr('queryid');
expect(sent_stanza.toString()).toBe(
"<iq type='set' xmlns='jabber:client' id='"+IQ_id+"'>"+
......@@ -202,7 +202,7 @@
converse_api.archive.query({
'start': '2010-06-07T00:00:00Z',
'after': '09af3-cc343-b409f',
'limit':10
'max':10
});
var queryid = $(sent_stanza.toString()).find('query').attr('queryid');
expect(sent_stanza.toString()).toBe(
......
......@@ -4,9 +4,10 @@ define("converse-dependencies", [
"otr",
"moment_with_locales",
"strophe",
"strophe.vcard",
"strophe.disco",
"strophe.ping",
"strophe.rsm",
"strophe.vcard",
"backbone.browserStorage",
"backbone.overview",
"jquery.browser",
......
......@@ -3,9 +3,10 @@ define("converse-dependencies", [
"utils",
"moment_with_locales",
"strophe",
"strophe.vcard",
"strophe.disco",
"strophe.ping",
"strophe.rsm",
"strophe.vcard",
"backbone.browserStorage",
"backbone.overview",
"jquery.browser",
......
......@@ -3,9 +3,10 @@ define("converse-dependencies", [
"utils",
"moment_with_locales",
"strophe",
"strophe.vcard",
"strophe.disco",
"strophe.ping",
"strophe.rsm",
"strophe.vcard",
"bootstrapJS", // XXX: Can be removed, only for https://conversejs.org
"backbone.browserStorage",
"backbone.overview",
......
......@@ -5,9 +5,10 @@ define("converse-dependencies", [
"otr",
"moment_with_locales",
"strophe",
"strophe.vcard",
"strophe.disco",
"strophe.ping",
"strophe.rsm",
"strophe.vcard",
"bootstrapJS", // XXX: Only for https://conversejs.org
"backbone.browserStorage",
"backbone.overview",
......
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