Don't ignore groupchat messages that also contain a CSN

This commit is contained in:
JC Brand 2020-03-23 20:54:27 +01:00
parent 57709b2e78
commit 5e27579ebe
2 changed files with 26 additions and 1 deletions

View File

@ -116,6 +116,30 @@
done(); done();
})); }));
it("can contain a chat state notification and will still be shown",
mock.initConverse(
['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) {
const muc_jid = 'lounge@montague.lit';
await test_utils.openAndEnterChatRoom(_converse, muc_jid, 'romeo');
const view = _converse.api.chatviews.get(muc_jid);
if (!view.el.querySelectorAll('.chat-area').length) { view.renderChatArea(); }
const message = 'romeo: Your attention is required';
const nick = mock.chatroom_names[0],
msg = $msg({
from: 'lounge@montague.lit/'+nick,
id: u.getUniqueId(),
to: 'romeo@montague.lit',
type: 'groupchat'
}).c('body').t(message)
.c('active', {'xmlns': "http://jabber.org/protocol/chatstates"})
.tree();
await view.model.queueMessage(msg);
await new Promise(resolve => view.once('messageInserted', resolve));
expect(view.el.querySelector('.chat-msg')).not.toBe(null);
done();
}));
it("is specially marked when you are mentioned in it", it("is specially marked when you are mentioned in it",
mock.initConverse( mock.initConverse(

View File

@ -1950,7 +1950,8 @@ converse.plugins.add('converse-muc', {
if (attrs['chat_state']) { if (attrs['chat_state']) {
this.updateCSN(attrs); this.updateCSN(attrs);
} else if (u.shouldCreateGroupchatMessage(attrs)) { }
if (u.shouldCreateGroupchatMessage(attrs)) {
const msg = this.handleCorrection(attrs) || await this.createMessage(attrs); const msg = this.handleCorrection(attrs) || await this.createMessage(attrs);
this.incrementUnreadMsgCounter(msg); this.incrementUnreadMsgCounter(msg);
} }