Skip to content

Commit 3ef8a05

Browse files
committed
Merge pull request #37 from Destreyf/master
Support v0.3 of XEP-0313 (MAM)
2 parents 5e9028c + 7960520 commit 3ef8a05

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

mam/strophe.mam.v0.3.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* XEP-0313: Message Archive Management
2+
* Copyright (C) 2012 Kim Alvefur
3+
*
4+
* This file is MIT/X11 licensed. Please see the
5+
* LICENSE.txt file in the source package for more information.
6+
*
7+
* Modified by: Chris Tunbridge (github.com/Destreyf/)
8+
* Updated to support v0.3 of the XMPP XEP-0313 standard
9+
* http://xmpp.org/extensions/xep-0313.html
10+
*
11+
*/
12+
13+
Strophe.addConnectionPlugin('mam', {
14+
_c: null,
15+
_p: [ "with", "start", "end" ],
16+
init: function (conn) {
17+
this._c = conn;
18+
Strophe.addNamespace('MAM', 'urn:xmpp:mam:0');
19+
},
20+
query: function (jid, options) {
21+
var _p = this._p;
22+
var attr = {
23+
type:"set",
24+
id:jid
25+
};
26+
var mamAttr = {xmlns: Strophe.NS.MAM};
27+
var iq = $iq(attr).c("query", mamAttr).c('x',{xmlns:'jabber:x:data'});
28+
29+
iq.c('field',{var:"FORM_TYPE"}).c('value').t("urn:xmpp:mam:0").up().up();
30+
for (i = 0; i < this._p.length; i++) {
31+
var pn = _p[i];
32+
var p = options[pn];
33+
delete options[pn];
34+
if (!!p) {
35+
var f
36+
iq.c('field',{var:pn}).c('value').t(p).up().up();
37+
}
38+
}
39+
iq.up();
40+
41+
var onMessage = options["onMessage"];
42+
delete options['onMessage'];
43+
var onComplete = options["onComplete"];
44+
delete options['onComplete'];
45+
iq.cnode(new Strophe.RSM(options).toXML());
46+
47+
this._c.addHandler(onMessage, Strophe.NS.MAM, "message", null);
48+
return this._c.sendIQ(iq, onComplete);
49+
}
50+
});

0 commit comments

Comments
 (0)