XMPP For The Web/Win ::: XMPP-FTW (1.18.0) Flattr this

XEP-0313 Message Archive Management/MAM

Querying the archive

Querying the archive is achieved as follows with each of the keys being optional. The format of the rsm key follows that at result set management.

             /* "queryId": "query-id", */
             /* "with": "someone@example.com", */
             /* "start": "2013-10-01T12:00:00Z", */
             /* "end": "2013-11-01T12:00:00Z", */
             /* "rsm": ...RMS payload... */
            function(error, data) { console.log(error, data) }

Once a request is received the message archive will fire message stanzas to the user, once it is complete the callback will be called with a value of true for the `data` key.

Incoming archived messages

Upon firing the above request messages (if present) will be sent from your XMPP server and received using the event `xmpp.mam.message`.

This code extends the incoming chat message parser (documented here) but adds the additional key of `mam` with an example below:

            from: {
                domain: 'evilprofessor.co.uk',
                user: 'megan'
            content: 'Hello fine Lady!',
            format: 'plain',
            mam: {
                to: {
                    domain: 'evilprofessor.co.uk',
                    user: 'lloyd',
                    resource: 'car'
                id: '1234',
                queryId: 'query-id'
         /* delay: { 
                from: 'evilprofessor.co.uk',
                when: '2013-06-03T19:56Z',
                reason: 'Offline storage'
            }, */

Settting archive preferences

Setting archive preferences is performed as follows:

                "default": "roster",
             /* "always": [
                ], */
             /* "never": [
                ], */
            function(error, data) { console.log(error, data) }

On success `data` will simply be true.


Fork me on GitHub