소스 검색

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.
laszlovl 6 년 전
부모
커밋
565f7d9f74
3개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      dist/converse.js
  2. 1 1
      src/headless/converse-chatboxes.js
  3. 1 1
      src/headless/dist/converse-headless.js

+ 1 - 1
dist/converse.js

@@ -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));
 

+ 1 - 1
src/headless/converse-chatboxes.js

@@ -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));
 

+ 1 - 1
src/headless/dist/converse-headless.js

@@ -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));