0
votes

I've installed and configured Openfire server with Monitoring Service Plugin, in order to keep chat history.

When users are chatting in a public room, all chat messages are saved in the database, and I can see them when I select rows from belonging MySQL table.

One of my requirements is to enable users to see his "old" messages. To able to do that, IQ Stanzas has to be sent, which is really well explained on the following link: http://xmpp.org/extensions/xep-0136.html#manage

My IQ Stanza looks like:

<iq type="get" id="pref1" xmlns="jabber:client">
    <retrieve xmlns="urn:xmpp:archive" with="[email protected]" start="2016-07-11T06:27:45.140Z">
        <set xmlns="http://jabber.org/protocol/rsm">
            <max>30</max>
        </set>
    </retrieve>
</iq>

For that IQ Stanza, I receive the following output:

<iq xmlns="jabber:client" type="result" id="pref1" to="testuser@kfm/b2yg0qj04r">
    <chat xmlns="urn:xmpp:archive" with="[email protected]" start="2016-07-29T13:45:24.245Z">
        <from secs="0" jid="user1@kfm">
            <body>This is just test</body>
        </from>
        <from secs="0" jid="user1@kfm">
            <body>This is just test</body>
        </from>
        <from secs="0" jid="user1@kfm">
            <body>This is just test</body>
        </from>
        <to secs="7">
            <body>Who is testing?</body>
        </to>
        <to secs="0">
            <body>Who is testing?</body>
        </to>
        <to secs="0">
            <body>Who is testing?</body>
        </to>
        <from secs="8" jid="user1@kfm">
            <body>I'M testing</body>
        </from>
        <from secs="0" jid="user1@kfm">
            <body>I'M testing</body>
        </from>
        <from secs="0" jid="user1@kfm">
            <body>I'M testing</body>
        </from>
        <to secs="5">
            <body>Ok</body>
        </to>
        <to secs="0">
            <body>Ok</body>
        </to>
        <to secs="0">
            <body>Ok</body>
        </to>
        <to secs="1">
            <body>super</body>
        </to>
        <to secs="0">
            <body>super</body>
        </to>
        <to secs="0">
            <body>super</body>
        </to>
        <set xmlns="http://jabber.org/protocol/rsm">
            <first index="0">0</first>
            <last>14</last>
            <count>15</count>
        </set>
    </chat>
</iq>

Question 1

Only message body is returned in chat history, but not message attributes (for example when I send a message, I set additional attributes to it, and I need them in this chat history). Is there a way to enable this feature?

Question 2

Why the same message is returned multiple times? In my case, every message is returned 3 times, although, I sent message only once?

1

1 Answers

1
votes

Regarding Question 1

I have checked Monitoring Plugin code and it is returning message body only. As the source is openly available, you can get into it and make some modifications as per your need.

Regarding Question 2

Check in the database and confirm if message id is same because duplication can be due to resubmission of same message from client apps because of not getting acknowledgement from server.