Bugfix. Pass original_stanza to isDuplicate

This commit is contained in:
JC Brand 2018-12-06 12:08:00 +01:00
parent 79bfb45639
commit 5f00987578
3 changed files with 65 additions and 3 deletions

View File

@ -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

View File

@ -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(
`<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 () {

View File

@ -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'),