"secs" attribute of "from" and "to" Elements in Monitoring Plugin (Message Archiving / XEP-0136)

In XEP-0136: Message Archiving 4.6 section.

Quote: “The time in whole seconds of the message relative to the previous message in the collection (or, for the first message, relative to the start of the collection) SHOULD be specified with a ‘secs’ attribute.”

See the example 44. Receiving the first page of a collection

.

<from secs='0'><body>Art thou not Romeo, and a Montague?</body></from>
<to secs='**11**'><body>Neither, fair saint, if either thee dislike.</body></to>

.
[97 more messages]
.
<from secs='**9**'><body>How cam'st thou hither, tell me, and wherefore?</body></from>

.

The “secs” attribute is relative to the previous message, not always to the “start” in the “chat” element.

See **com.reucon.openfire.plugin.archive.xep0136.IQRetrieveHandler **line 96. (Openfire 3.9.3)

secs = (message.getTime().getTime() - conversation.getStart().getTime()) / 1000;

It should be

secs = (message.getTime().getTime() - **previousMessage**.getTime().getTime()) / 1000;

Thanks, but you created a document, which has reduced visibility. Please post in the forum.

Thanks, filed OF-856 on it and will submit a pull request with the patch

See com.reucon.openfire.plugin.archive.xep0136.IQRetrieveHandler
Modify line 71-73 to the following:
for (int i = 0; i < messages.size(); i++) {
if(i == 0){

    addMessageElement(chatElement, conversation, messages.get(i), null);

} else {

    addMessageElement(chatElement, conversation, messages.get(i), messages.get(i-1));

}

}

Modify line 91-92 to the following:
private Element addMessageElement(Element parentElement,
Conversation conversation, ArchivedMessage message, ArchivedMessage previousMessage ) {

Modify line 96 to the following:
if (previousMessage == null) {

secs = (message.getTime().getTime() - conversation.getStart().getTime()) / 1000;

} else {

secs = (message.getTime().getTime() - previousMessage.getTime().getTime()) / 1000;

}

PS: I do NOT write a unit test case to verify the correctness.

Hello all,

I’m sure this implementation is not precise. Due to roundoffs we get rising inaccuracy.

I propose:

Openfire/src/plugins/monitoring/src/java/com/reucon/openfire/plugin/archive/xep0 136/IQRetrieveHandler.java


Line 78:


long secs = 0;

for (int i = 0; i < messages.size(); i++) {

secs = secs + Long.parseLong(addMessageElement(chatElement, conversation, messages.get(i), secs).attributeValue(“secs”));

}


Line 104:


private Element addMessageElement(Element parentElement,

Conversation conversation, ArchivedMessage message, long SecondsSum) {

final Element messageElement;

final long secs;

secs = (message.getTime().getTime() - conversation.getStart().getTime()) / 1000 - SecondsSum;

Please submit this as a pull request against our Github project.