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;
Attempted to generate a patch for this, but am unsure of where previousMessage is defined...
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.
Hi Linus, Would you consider generating a github pull request with this suggested change?
He did. Initially, here: https://github.com/igniterealtime/Openfire/pull/161
Later, I cherry picked the commits for this JIRA issue here: https://github.com/igniterealtime/Openfire/pull/458