Select the immediate body, not the one in fallback.
This commit is contained in:
parent
fd9e41a917
commit
17e5804be7
@ -13,6 +13,7 @@
|
||||
- Restrict editing of MUC messages to ones with the same XEP-0421 occupant ID
|
||||
- #2936: Fix documentation about enable_smacks option, which is true by default.
|
||||
- #2925: Fix missing disco-items in browser storage.
|
||||
- Fix MUC messages with a fallback body not rendering.
|
||||
|
||||
## 9.1.1 (2022-05-05)
|
||||
|
||||
|
@ -224,7 +224,7 @@ export async function parseMUCMessage (stanza, chatbox) {
|
||||
{
|
||||
from,
|
||||
'activities': getMEPActivities(stanza),
|
||||
'body': stanza.querySelector('body')?.textContent?.trim(),
|
||||
'body': stanza.querySelector(':scope > body')?.textContent?.trim(),
|
||||
'chat_state': getChatState(stanza),
|
||||
'from_muc': Strophe.getBareJidFromJid(from),
|
||||
'is_archived': isArchived(original_stanza),
|
||||
|
@ -117,4 +117,26 @@ describe("A MUC message", function () {
|
||||
const model = _converse.chatboxes.get(muc_jid);
|
||||
expect(model.messages.length).toBe(0);
|
||||
}));
|
||||
|
||||
it('parses the correct body element',
|
||||
mock.initConverse(['chatBoxesFetched'], {}, async function(_converse) {
|
||||
|
||||
const muc_jid = 'lounge@montague.lit';
|
||||
const model = await mock.openAndEnterChatRoom(_converse, muc_jid, 'romeo');
|
||||
const received_stanza = u.toStanza(`
|
||||
<message to='${_converse.jid}' from='${muc_jid}/mallory' type='groupchat' id='${_converse.connection.getUniqueId()}' >
|
||||
<reply xmlns='urn:xmpp:reply:0' id='${_converse.connection.getUniqueId()}' to='${_converse.jid}'/>
|
||||
<fallback xmlns='urn:xmpp:feature-fallback:0' for='urn:xmpp:reply:0'>
|
||||
<body start='0' end='10'/>
|
||||
</fallback>
|
||||
<active xmlns='http://jabber.org/protocol/chatstates'/>
|
||||
<body>> ping
|
||||
pong</body>
|
||||
<request xmlns='urn:xmpp:receipts'/>
|
||||
</message>
|
||||
`);
|
||||
await model.handleMessageStanza(received_stanza);
|
||||
await u.waitUntil(() => model.messages.last());
|
||||
expect(model.messages.last().get('body')).toBe('> ping\npong');
|
||||
}));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user