From 5f00987578c4ead64edc363c981f703d9d22054b Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 6 Dec 2018 12:08:00 +0100 Subject: [PATCH] Bugfix. Pass original_stanza to `isDuplicate` --- CHANGES.md | 1 + spec/mam.js | 62 +++++++++++++++++++++++++++++++++++- src/headless/converse-muc.js | 5 +-- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 78eeb328a..9e24c60e6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ - Don't render http (i.e. non-TLS) resources - Bugfix: Converse caused `RID out of range` errors on Prosody +- Bugfix: MUC messages sometimes appear twice after resync. - #1331 Fix missing checkmarks in old muc messages - #1333 Don't send receipt requests in MUCs diff --git a/spec/mam.js b/spec/mam.js index c049de6c5..971fe53d7 100644 --- a/spec/mam.js +++ b/spec/mam.js @@ -15,7 +15,7 @@ describe("Archived Messages", function () { - it("aren't shown as duplicates", + it("aren't shown as duplicates by comparing their stanza-id attribute", mock.initConverseWithPromises( null, ['discoInitialized'], {}, async function (done, _converse) { @@ -57,7 +57,67 @@ done(); })); + it("aren't shown as duplicates by comparing their queryid attribute", + mock.initConverseWithPromises( + null, ['discoInitialized'], {}, + async function (done, _converse) { + await test_utils.openAndEnterChatRoom(_converse, 'discuss', 'conference.conversejs.org', 'dummy'); + const view = _converse.chatboxviews.get('discuss@conference.conversejs.org'); + let stanza = Strophe.xmlHtmlNode( + ` + + looks like omemo fails completely with "bundle is undefined" when there is a device in the devicelist that has no keys published + + + + `).firstElementChild; + _converse.connection._dataRecv(test_utils.createRequest(stanza)); + await test_utils.waitUntil(() => view.content.querySelectorAll('.chat-msg').length); + + stanza = Strophe.xmlHtmlNode( + ` + + + + + looks like omemo fails completely with "bundle is undefined" when there is a device in the devicelist that has no keys published + + + + + + + `).firstElementChild; + + spyOn(view.model, 'isDuplicate').and.callThrough(); + view.model.onMessage(stanza); + await test_utils.waitUntil(() => view.model.isDuplicate.calls.count()); + expect(view.model.isDuplicate.calls.count()).toBe(1); + expect(view.content.querySelectorAll('.chat-msg').length).toBe(1); + + stanza = Strophe.xmlHtmlNode( + ` + + + + + looks like omemo fails completely with "bundle is undefined" when there is a device in the devicelist that has no keys published + + + + + + + `).firstElementChild; + view.model.onMessage(stanza); + expect(view.model.isDuplicate.calls.count()).toBe(2); + expect(view.content.querySelectorAll('.chat-msg').length).toBe(1); + done(); + })) }); describe("The archive.query API", function () { diff --git a/src/headless/converse-muc.js b/src/headless/converse-muc.js index 52171509a..deee355b3 100644 --- a/src/headless/converse-muc.js +++ b/src/headless/converse-muc.js @@ -915,7 +915,8 @@ converse.plugins.add('converse-muc', { return data; }, - isDuplicate (message) { + isDuplicate (message, original_stanza) { + // XXX: original_stanza is not used here, but in converse-mam const msgid = message.getAttribute('id'), jid = message.getAttribute('from'); @@ -958,7 +959,7 @@ converse.plugins.add('converse-muc', { if (forwarded) { stanza = forwarded.querySelector('message'); } - if (this.isDuplicate(stanza)) { + if (this.isDuplicate(stanza, original_stanza)) { return; } const jid = stanza.getAttribute('from'),