Monitoring plugin uses secs attribute relative from beginning message instead of last message


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;




Guus der Kinderen
December 16, 2015, 9:30 AM

He did. Initially, here:
Later, I cherry picked the commits for this JIRA issue here:

Daryl Herzmann
November 2, 2015, 5:19 PM

Hi Linus, Would you consider generating a github pull request with this suggested change?

December 5, 2014, 1:09 AM

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.

Daryl Herzmann
December 4, 2014, 9:54 PM

Attempted to generate a patch for this, but am unsure of where previousMessage is defined...



Dave Cridland


Daryl Herzmann