Commit abe21dce authored by JC Brand's avatar JC Brand

Include `origin-id` in outgoing messages

parent 590d8769
...@@ -61761,23 +61761,23 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -61761,23 +61761,23 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
'id': message.get('edited') && _converse.connection.getUniqueId() || message.get('msgid') 'id': message.get('edited') && _converse.connection.getUniqueId() || message.get('msgid')
}).c('body').t(message.get('message')).up().c(_converse.ACTIVE, { }).c('body').t(message.get('message')).up().c(_converse.ACTIVE, {
'xmlns': Strophe.NS.CHATSTATES 'xmlns': Strophe.NS.CHATSTATES
}).up(); }).root();
if (message.get('type') === 'chat') { if (message.get('type') === 'chat') {
stanza.c('request', { stanza.c('request', {
'xmlns': Strophe.NS.RECEIPTS 'xmlns': Strophe.NS.RECEIPTS
}).up(); }).root();
} }
if (message.get('is_spoiler')) { if (message.get('is_spoiler')) {
if (message.get('spoiler_hint')) { if (message.get('spoiler_hint')) {
stanza.c('spoiler', { stanza.c('spoiler', {
'xmlns': Strophe.NS.SPOILER 'xmlns': Strophe.NS.SPOILER
}, message.get('spoiler_hint')).up(); }, message.get('spoiler_hint')).root();
} else { } else {
stanza.c('spoiler', { stanza.c('spoiler', {
'xmlns': Strophe.NS.SPOILER 'xmlns': Strophe.NS.SPOILER
}).up(); }).root();
} }
} }
...@@ -61793,20 +61793,27 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -61793,20 +61793,27 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
attrs.uri = reference.uri; attrs.uri = reference.uri;
} }
stanza.c('reference', attrs).up(); stanza.c('reference', attrs).root();
}); });
if (message.get('oob_url')) { if (message.get('oob_url')) {
stanza.c('x', { stanza.c('x', {
'xmlns': Strophe.NS.OUTOFBAND 'xmlns': Strophe.NS.OUTOFBAND
}).c('url').t(message.get('oob_url')).up(); }).c('url').t(message.get('oob_url')).root();
} }
if (message.get('edited')) { if (message.get('edited')) {
stanza.c('replace', { stanza.c('replace', {
'xmlns': Strophe.NS.MESSAGE_CORRECT, 'xmlns': Strophe.NS.MESSAGE_CORRECT,
'id': message.get('msgid') 'id': message.get('msgid')
}).up(); }).root();
}
if (message.get('origin_id')) {
stanza.c('origin-id', {
'xmlns': Strophe.NS.SID,
'id': message.get('origin_id')
}).root();
} }
return stanza; return stanza;
...@@ -61833,6 +61840,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -61833,6 +61840,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
const is_spoiler = this.get('composing_spoiler'); const is_spoiler = this.get('composing_spoiler');
return _.extend(this.toJSON(), { return _.extend(this.toJSON(), {
'id': _converse.connection.getUniqueId(), 'id': _converse.connection.getUniqueId(),
'origin_id': _converse.connection.getUniqueId(),
'fullname': _converse.xmppstatus.get('fullname'), 'fullname': _converse.xmppstatus.get('fullname'),
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'sender': 'me', 'sender': 'me',
...@@ -66308,6 +66316,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc ...@@ -66308,6 +66316,7 @@ _converse_core__WEBPACK_IMPORTED_MODULE_6__["default"].plugins.add('converse-muc
text = _this$parseTextForRef2[0]; text = _this$parseTextForRef2[0];
references = _this$parseTextForRef2[1]; references = _this$parseTextForRef2[1];
return { return {
'origin_id': _converse.connection.getUniqueId(),
'from': `${this.get('jid')}/${this.get('nick')}`, 'from': `${this.get('jid')}/${this.get('nick')}`,
'fullname': this.get('nick'), 'fullname': this.get('nick'),
'is_spoiler': is_spoiler, 'is_spoiler': is_spoiler,
...@@ -362,6 +362,7 @@ ...@@ -362,6 +362,7 @@
`<x xmlns="jabber:x:oob">`+ `<x xmlns="jabber:x:oob">`+
`<url>${message}</url>`+ `<url>${message}</url>`+
`</x>`+ `</x>`+
`<origin-id id="${sent_stanza.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
`</message>`); `</message>`);
await test_utils.waitUntil(() => view.el.querySelector('.chat-image'), 1000); await test_utils.waitUntil(() => view.el.querySelector('.chat-image'), 1000);
// Check that the image renders // Check that the image renders
...@@ -464,6 +465,7 @@ ...@@ -464,6 +465,7 @@
`<x xmlns="jabber:x:oob">`+ `<x xmlns="jabber:x:oob">`+
`<url>${message}</url>`+ `<url>${message}</url>`+
`</x>`+ `</x>`+
`<origin-id id="${sent_stanza.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
`</message>`); `</message>`);
await test_utils.waitUntil(() => view.el.querySelector('.chat-image'), 1000); await test_utils.waitUntil(() => view.el.querySelector('.chat-image'), 1000);
// Check that the image renders // Check that the image renders
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+ `<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<request xmlns="urn:xmpp:receipts"/>`+ `<request xmlns="urn:xmpp:receipts"/>`+
`<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+ `<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
`</message>`); `</message>`);
expect(view.model.messages.models.length).toBe(1); expect(view.model.messages.models.length).toBe(1);
const corrected_message = view.model.messages.at(0); const corrected_message = view.model.messages.at(0);
...@@ -177,6 +178,7 @@ ...@@ -177,6 +178,7 @@
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+ `<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<request xmlns="urn:xmpp:receipts"/>`+ `<request xmlns="urn:xmpp:receipts"/>`+
`<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+ `<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
`</message>`); `</message>`);
expect(view.model.messages.models.length).toBe(1); expect(view.model.messages.models.length).toBe(1);
const corrected_message = view.model.messages.at(0); const corrected_message = view.model.messages.at(0);
...@@ -2269,6 +2271,7 @@ ...@@ -2269,6 +2271,7 @@
`<body>But soft, what light through yonder window breaks?</body>`+ `<body>But soft, what light through yonder window breaks?</body>`+
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+ `<active xmlns="http://jabber.org/protocol/chatstates"/>`+
`<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+ `<replace id="${first_msg.get("msgid")}" xmlns="urn:xmpp:message-correct:0"/>`+
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
`</message>`); `</message>`);
expect(view.model.messages.models.length).toBe(1); expect(view.model.messages.models.length).toBe(1);
...@@ -2492,6 +2495,7 @@ ...@@ -2492,6 +2495,7 @@
`<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@localhost" xmlns="urn:xmpp:reference:0"/>`+ `<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference begin="11" end="17" type="mention" uri="xmpp:gibson@localhost" xmlns="urn:xmpp:reference:0"/>`+ `<reference begin="11" end="17" type="mention" uri="xmpp:gibson@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@localhost" xmlns="urn:xmpp:reference:0"/>`+ `<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
`</message>`); `</message>`);
const first_msg = view.model.messages.findWhere({'message': 'hello z3r0 gibson mr.robot, how are you?'}); const first_msg = view.model.messages.findWhere({'message': 'hello z3r0 gibson mr.robot, how are you?'});
...@@ -2518,6 +2522,7 @@ ...@@ -2518,6 +2522,7 @@
`<reference begin="11" end="17" type="mention" uri="xmpp:gibson@localhost" xmlns="urn:xmpp:reference:0"/>`+ `<reference begin="11" end="17" type="mention" uri="xmpp:gibson@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@localhost" xmlns="urn:xmpp:reference:0"/>`+ `<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<replace id="${msg.nodeTree.getAttribute("id")}" xmlns="urn:xmpp:message-correct:0"/>`+ `<replace id="${msg.nodeTree.getAttribute("id")}" xmlns="urn:xmpp:message-correct:0"/>`+
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
`</message>`); `</message>`);
done(); done();
})); }));
...@@ -2565,6 +2570,7 @@ ...@@ -2565,6 +2570,7 @@
`<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@localhost" xmlns="urn:xmpp:reference:0"/>`+ `<reference begin="18" end="26" type="mention" uri="xmpp:mr.robot@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference begin="11" end="17" type="mention" uri="xmpp:gibson@localhost" xmlns="urn:xmpp:reference:0"/>`+ `<reference begin="11" end="17" type="mention" uri="xmpp:gibson@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@localhost" xmlns="urn:xmpp:reference:0"/>`+ `<reference begin="6" end="10" type="mention" uri="xmpp:z3r0@localhost" xmlns="urn:xmpp:reference:0"/>`+
`<origin-id id="${msg.nodeTree.querySelector('origin-id').getAttribute("id")}" xmlns="urn:xmpp:sid:0"/>`+
`</message>`); `</message>`);
done(); done();
}).catch(_.partial(console.error, _)); }).catch(_.partial(console.error, _));
......
...@@ -401,15 +401,16 @@ converse.plugins.add('converse-chatboxes', { ...@@ -401,15 +401,16 @@ converse.plugins.add('converse-chatboxes', {
'type': this.get('message_type'), 'type': this.get('message_type'),
'id': message.get('edited') && _converse.connection.getUniqueId() || message.get('msgid'), 'id': message.get('edited') && _converse.connection.getUniqueId() || message.get('msgid'),
}).c('body').t(message.get('message')).up() }).c('body').t(message.get('message')).up()
.c(_converse.ACTIVE, {'xmlns': Strophe.NS.CHATSTATES}).up(); .c(_converse.ACTIVE, {'xmlns': Strophe.NS.CHATSTATES}).root();
if (message.get('type') === 'chat') { if (message.get('type') === 'chat') {
stanza.c('request', {'xmlns': Strophe.NS.RECEIPTS}).up(); stanza.c('request', {'xmlns': Strophe.NS.RECEIPTS}).root();
} }
if (message.get('is_spoiler')) { if (message.get('is_spoiler')) {
if (message.get('spoiler_hint')) { if (message.get('spoiler_hint')) {
stanza.c('spoiler', {'xmlns': Strophe.NS.SPOILER}, message.get('spoiler_hint')).up(); stanza.c('spoiler', {'xmlns': Strophe.NS.SPOILER}, message.get('spoiler_hint')).root();
} else { } else {
stanza.c('spoiler', {'xmlns': Strophe.NS.SPOILER}).up(); stanza.c('spoiler', {'xmlns': Strophe.NS.SPOILER}).root();
} }
} }
(message.get('references') || []).forEach(reference => { (message.get('references') || []).forEach(reference => {
...@@ -422,17 +423,20 @@ converse.plugins.add('converse-chatboxes', { ...@@ -422,17 +423,20 @@ converse.plugins.add('converse-chatboxes', {
if (reference.uri) { if (reference.uri) {
attrs.uri = reference.uri; attrs.uri = reference.uri;
} }
stanza.c('reference', attrs).up(); stanza.c('reference', attrs).root();
}); });
if (message.get('oob_url')) { if (message.get('oob_url')) {
stanza.c('x', {'xmlns': Strophe.NS.OUTOFBAND}).c('url').t(message.get('oob_url')).up(); stanza.c('x', {'xmlns': Strophe.NS.OUTOFBAND}).c('url').t(message.get('oob_url')).root();
} }
if (message.get('edited')) { if (message.get('edited')) {
stanza.c('replace', { stanza.c('replace', {
'xmlns': Strophe.NS.MESSAGE_CORRECT, 'xmlns': Strophe.NS.MESSAGE_CORRECT,
'id': message.get('msgid') 'id': message.get('msgid')
}).up(); }).root();
}
if (message.get('origin_id')) {
stanza.c('origin-id', {'xmlns': Strophe.NS.SID, 'id': message.get('origin_id')}).root();
} }
return stanza; return stanza;
}, },
...@@ -459,6 +463,7 @@ converse.plugins.add('converse-chatboxes', { ...@@ -459,6 +463,7 @@ converse.plugins.add('converse-chatboxes', {
const is_spoiler = this.get('composing_spoiler'); const is_spoiler = this.get('composing_spoiler');
return _.extend(this.toJSON(), { return _.extend(this.toJSON(), {
'id': _converse.connection.getUniqueId(), 'id': _converse.connection.getUniqueId(),
'origin_id': _converse.connection.getUniqueId(),
'fullname': _converse.xmppstatus.get('fullname'), 'fullname': _converse.xmppstatus.get('fullname'),
'from': _converse.bare_jid, 'from': _converse.bare_jid,
'sender': 'me', 'sender': 'me',
......
...@@ -405,6 +405,7 @@ converse.plugins.add('converse-muc', { ...@@ -405,6 +405,7 @@ converse.plugins.add('converse-muc', {
[text, references] = this.parseTextForReferences(text); [text, references] = this.parseTextForReferences(text);
return { return {
'origin_id': _converse.connection.getUniqueId(),
'from': `${this.get('jid')}/${this.get('nick')}`, 'from': `${this.get('jid')}/${this.get('nick')}`,
'fullname': this.get('nick'), 'fullname': this.get('nick'),
'is_spoiler': is_spoiler, 'is_spoiler': is_spoiler,
......
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