Commit 565f7d9f authored by laszlovl's avatar laszlovl Committed by JC Brand

Make sure the time attribute for MAM message is parsed through moment

Messages (received directly or via MAM) are stored in a backbone
collection that's kept sorted by the message's "time" attribute.
Various parts of the codebase rely on this behavior.

For regular messages, the time attribute is generated by
`moment().format()`, which generates a timestamp in the browser's
local timezone, for example "...+02:00".

For MAM messages, we would previously copy the "delay.stamp" value
into the "time" attribute verbatim. However, that value is generated
by the server and is unlikely to be in the same timezone locale.

ISO timestamps expressed in different timezones cannot be sorted
lexicographically, breaking the premise of keeping the messages
collection sorted by time.
parent 15b22736
......@@ -62855,7 +62855,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
'references': this.getReferencesFromStanza(stanza),
'subject': _.propertyOf(stanza.querySelector('subject'))('textContent'),
'thread': _.propertyOf(stanza.querySelector('thread'))('textContent'),
'time': delay ? delay.getAttribute('stamp') : moment().format(),
'time': delay ? moment(delay.getAttribute('stamp')).format() : moment().format(),
'type': stanza.getAttribute('type')
}, this.getStanzaIDs(original_stanza));
......@@ -747,7 +747,7 @@ converse.plugins.add('converse-chatboxes', {
'references': this.getReferencesFromStanza(stanza),
'subject': _.propertyOf(stanza.querySelector('subject'))('textContent'),
'thread': _.propertyOf(stanza.querySelector('thread'))('textContent'),
'time': delay ? delay.getAttribute('stamp') : moment().format(),
'time': delay ? moment(delay.getAttribute('stamp')).format() : moment().format(),
'type': stanza.getAttribute('type')
}, this.getStanzaIDs(original_stanza));
......
......@@ -41102,7 +41102,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
'references': this.getReferencesFromStanza(stanza),
'subject': _.propertyOf(stanza.querySelector('subject'))('textContent'),
'thread': _.propertyOf(stanza.querySelector('thread'))('textContent'),
'time': delay ? delay.getAttribute('stamp') : moment().format(),
'time': delay ? moment(delay.getAttribute('stamp')).format() : moment().format(),
'type': stanza.getAttribute('type')
}, this.getStanzaIDs(original_stanza));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment