metajack/strophejs-plugins

Getting duplicates messages from mam query

LTroya opened this issue · 0 comments

Is there a way to retrieve messages from two chats at the same time?

I try

[jid1, jid2].forEach(function (jid) {
    connect.mam.query(Strophe.getBareJidFromJid(connect.jid), getQuery(jid));
});

function getQuery(jid) {
        return {
            with: jid + '@domain.com',
            max: 5,
            before: '',
            onMessage: function (message) {
                  // my code
            },
            onComplete: function (response) {
                // my code
            }
        };
    }

Also tried using onCompleted callback

function getQuery(jid) {
        return {
            with: jid + '@domain.com',
            max: 5,
            before: '',
            onMessage: function (message) {
                  // my code
            },
            onComplete: function (response) {
                // my code
                connect.mam.query(Strophe.getBareJidFromJid(connect.jid), getQuery(nextJID));
            }
        };
    }

This two ways to trying to do the same thing results as duplicates message from the ejabberd server.

I am using Ejabberd Server and Strophejs on the client