Commit 5f009875 authored by JC Brand's avatar JC Brand

Bugfix. Pass original_stanza to `isDuplicate`

parent 79bfb456
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
- Don't render http (i.e. non-TLS) resources - Don't render http (i.e. non-TLS) resources
- Bugfix: Converse caused `RID out of range` errors on Prosody - 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 - #1331 Fix missing checkmarks in old muc messages
- #1333 Don't send receipt requests in MUCs - #1333 Don't send receipt requests in MUCs
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
describe("Archived Messages", function () { describe("Archived Messages", function () {
it("aren't shown as duplicates", it("aren't shown as duplicates by comparing their stanza-id attribute",
mock.initConverseWithPromises( mock.initConverseWithPromises(
null, ['discoInitialized'], {}, null, ['discoInitialized'], {},
async function (done, _converse) { async function (done, _converse) {
...@@ -57,7 +57,67 @@ ...@@ -57,7 +57,67 @@
done(); 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(
`<message xmlns="jabber:client"
to="discuss@conference.conversejs.org"
type="groupchat" xml:lang="en"
from="discuss@conference.conversejs.org/prezel">
<stanza-id xmlns="urn:xmpp:sid:0" id="7a9fde91-4387-4bf8-b5d3-978dab8f6bf3" by="discuss@conference.conversejs.org"/>
<body>looks like omemo fails completely with "bundle is undefined" when there is a device in the devicelist that has no keys published</body>
<x xmlns="http://jabber.org/protocol/muc#user">
<item affiliation="none" jid="prezel@blubber.im" role="participant"/>
</x>
</message>`).firstElementChild;
_converse.connection._dataRecv(test_utils.createRequest(stanza));
await test_utils.waitUntil(() => view.content.querySelectorAll('.chat-msg').length);
stanza = Strophe.xmlHtmlNode(
`<message xmlns="jabber:client" to="dummy@localhost/resource" from="discuss@conference.conversejs.org">
<result xmlns="urn:xmpp:mam:2" queryid="06fea9ca-97c9-48c4-8583-009ff54ea2e8" id="7a9fde91-4387-4bf8-b5d3-978dab8f6bf3">
<forwarded xmlns="urn:xmpp:forward:0">
<delay xmlns="urn:xmpp:delay" stamp="2018-12-05T04:53:12Z"/>
<message xmlns="jabber:client" to="discuss@conference.conversejs.org" type="groupchat" xml:lang="en" from="discuss@conference.conversejs.org/prezel">
<body>looks like omemo fails completely with "bundle is undefined" when there is a device in the devicelist that has no keys published</body>
<x xmlns="http://jabber.org/protocol/muc#user">
<item affiliation="none" jid="prezel@blubber.im" role="participant"/>
</x>
</message>
</forwarded>
</result>
</message>`).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(
`<message xmlns="jabber:client" to="dummy@localhost/resource" from="discuss@conference.conversejs.org">
<result xmlns="urn:xmpp:mam:2" queryid="06fea9ca-97c9-48c4-8583-009ff54ea2e8" id="7a9fde91-4387-4bf8-b5d3-978dab8f6bf3">
<forwarded xmlns="urn:xmpp:forward:0">
<delay xmlns="urn:xmpp:delay" stamp="2018-12-05T04:53:12Z"/>
<message xmlns="jabber:client" to="discuss@conference.conversejs.org" type="groupchat" xml:lang="en" from="discuss@conference.conversejs.org/prezel">
<body>looks like omemo fails completely with "bundle is undefined" when there is a device in the devicelist that has no keys published</body>
<x xmlns="http://jabber.org/protocol/muc#user">
<item affiliation="none" jid="prezel@blubber.im" role="participant"/>
</x>
</message>
</forwarded>
</result>
</message>`).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 () { describe("The archive.query API", function () {
......
...@@ -915,7 +915,8 @@ converse.plugins.add('converse-muc', { ...@@ -915,7 +915,8 @@ converse.plugins.add('converse-muc', {
return data; return data;
}, },
isDuplicate (message) { isDuplicate (message, original_stanza) {
// XXX: original_stanza is not used here, but in converse-mam
const msgid = message.getAttribute('id'), const msgid = message.getAttribute('id'),
jid = message.getAttribute('from'); jid = message.getAttribute('from');
...@@ -958,7 +959,7 @@ converse.plugins.add('converse-muc', { ...@@ -958,7 +959,7 @@ converse.plugins.add('converse-muc', {
if (forwarded) { if (forwarded) {
stanza = forwarded.querySelector('message'); stanza = forwarded.querySelector('message');
} }
if (this.isDuplicate(stanza)) { if (this.isDuplicate(stanza, original_stanza)) {
return; return;
} }
const jid = stanza.getAttribute('from'), const jid = stanza.getAttribute('from'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment