Procházet zdrojové kódy

Fixes #2118. Show reflected message in MUC

JC Brand před 4 měsíci
rodič
revize
a8442d197c

+ 1 - 0
CHANGES.md

@@ -13,6 +13,7 @@
 - #1195: Add actions to quote and copy messages
 - #1303: Display non-contacts who sent us a message somehow in fullscreen 
 - #1349: XEP-0392 Consistent Color Generation
+- #2118: Show reflected message in MUC 
 - #2383: Add modal to start chats with JIDs not in the roster
 - #2586: Add support for XEP-0402 Bookmarks
 - #2623: Merge MUC join and bookmark, leave and unset autojoin 

+ 5 - 1
src/headless/plugins/muc/muc.js

@@ -1996,7 +1996,11 @@ class MUC extends ModelWithMessages(ColorAwareModel(ChatBoxBase)) {
 
         if (this.isOwnMessage(attrs)) {
             const stanza_id_keys = Object.keys(attrs).filter((k) => k.startsWith('stanza_id'));
-            Object.assign(new_attrs, pick(attrs, stanza_id_keys));
+            Object.assign(
+                new_attrs,
+                { ...pick(attrs, stanza_id_keys) },
+                { body: attrs.body }
+            );
             if (!message.get('received')) {
                 new_attrs.received = new Date().toISOString();
             }

+ 2 - 2
src/plugins/muc-views/tests/muc-messages.js

@@ -290,7 +290,7 @@ describe("A Groupchat Message", function () {
         expect(view.model.messages.last().occupant.get('nick')).toBe('some1');
     }));
 
-    it("will be shown as received upon MUC reflection",
+    it("will be shown as received and have its body updated upon MUC reflection",
             mock.initConverse([], {}, async function (_converse) {
 
         await mock.waitForRoster(_converse, 'current');
@@ -316,7 +316,7 @@ describe("A Groupchat Message", function () {
                      from="${msg_obj.get('from')}"
                      to="${_converse.api.connection.get().jid}"
                      type="groupchat">
-                <body>${msg_obj.get('message')}</body>
+                <body>${msg_obj.get('message').substring(0, 10) + '...'}</body>
                 <stanza-id xmlns="urn:xmpp:sid:0"
                            id="5f3dbc5e-e1d3-4077-a492-693f3769c7ad"
                            by="lounge@montague.lit"/>