Skip to content

Commit 1dfdb36

Browse files
committed
Don't filter out own device when sending OMEMO message
1 parent 9653636 commit 1dfdb36

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- New config setting [locked_muc_nickname](https://conversejs.org/docs/html/configuration.html#locked-muc-nickname)
1919
- New config setting [show_client_info](https://conversejs.org/docs/html/configuration.html#show-client-info)
2020
- Document new API method [sendMessage](https://conversejs.org/docs/html/api/-_converse.ChatBox.html#sendMessage)
21+
- Don't filter out own device when sending an OMEMO message
2122
- #1149: With `xhr_user_search_url`, contact requests are not being sent out
2223
- #1213: Switch roster filter input and icons
2324
- #1327: fix False mentions positives in URLs and Email addresses

dist/converse.js

+2-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/omemo.js

+5
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
`<encrypted xmlns="eu.siacs.conversations.axolotl">`+
180180
`<header sid="123456789">`+
181181
`<key rid="482886413b977930064a5888b92134fe">YzFwaDNSNzNYNw==</key>`+
182+
`<key rid="123456789">YzFwaDNSNzNYNw==</key>`+
182183
`<key rid="555">YzFwaDNSNzNYNw==</key>`+
183184
`<iv>${sent_stanza.nodeTree.querySelector("iv").textContent}</iv>`+
184185
`</header>`+
@@ -258,6 +259,7 @@
258259
toggle.click();
259260
expect(view.model.get('omemo_active')).toBe(true);
260261

262+
// newguy enters the room
261263
const contact_jid = 'newguy@localhost';
262264
let stanza = $pres({
263265
'to': 'dummy@localhost/resource',
@@ -271,6 +273,7 @@
271273
}).tree();
272274
_converse.connection._dataRecv(test_utils.createRequest(stanza));
273275

276+
// Wait for Converse to fetch newguy's device list
274277
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, contact_jid));
275278
expect(iq_stanza.toLocaleString()).toBe(
276279
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" to="${contact_jid}" type="get" xmlns="jabber:client">`+
@@ -279,6 +282,7 @@
279282
`</pubsub>`+
280283
`</iq>`);
281284

285+
// The server returns his device list
282286
stanza = $iq({
283287
'from': contact_jid,
284288
'id': iq_stanza.nodeTree.getAttribute('id'),
@@ -366,6 +370,7 @@
366370
`<encrypted xmlns="eu.siacs.conversations.axolotl">`+
367371
`<header sid="123456789">`+
368372
`<key rid="482886413b977930064a5888b92134fe">YzFwaDNSNzNYNw==</key>`+
373+
`<key rid="123456789">YzFwaDNSNzNYNw==</key>`+
369374
`<key rid="4e30f35051b7b8b42abe083742187228">YzFwaDNSNzNYNw==</key>`+
370375
`<iv>${sent_stanza.nodeTree.querySelector("iv").textContent}</iv>`+
371376
`</header>`+

src/converse-omemo.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -549,20 +549,14 @@ converse.plugins.add('converse-omemo', {
549549

550550
_converse.getBundlesAndBuildSessions = async function (chatbox) {
551551
let devices;
552-
const id = _converse.omemo_store.get('device_id');
553552
if (chatbox.get('type') === _converse.CHATROOMS_TYPE) {
554553
const collections = await Promise.all(chatbox.occupants.map(o => getDevicesForContact(o.get('jid'))));
555554
devices = collections.reduce((a, b) => _.concat(a, b.models), []);
556-
557555
} else if (chatbox.get('type') === _converse.PRIVATE_CHAT_TYPE) {
558556
const their_devices = await getDevicesForContact(chatbox.get('jid')),
559-
devicelist = _converse.devicelists.get(_converse.bare_jid),
560-
own_devices = devicelist.devices.filter(d => d.get('id') !== id);
561-
devices = _.concat(own_devices, their_devices.models);
557+
own_devices = _converse.devicelists.get(_converse.bare_jid).devices;
558+
devices = _.concat(own_devices.models, their_devices.models);
562559
}
563-
// Filter out our own device
564-
devices = devices.filter(d => d.get('id') !== id);
565-
566560
await Promise.all(devices.map(d => d.getBundle()));
567561
await Promise.all(devices.map(d => getSession(d)));
568562
return devices;
@@ -613,7 +607,7 @@ converse.plugins.add('converse-omemo', {
613607
// and they are separately encrypted using the
614608
// session corresponding to the counterpart device.
615609
stanza.c('encrypted', {'xmlns': Strophe.NS.OMEMO})
616-
.c('header', {'sid': _converse.omemo_store.get('device_id')});
610+
.c('header', {'sid': _converse.omemo_store.get('device_id')});
617611

618612
return chatbox.encryptMessage(message.get('message')).then(obj => {
619613
// The 16 bytes key and the GCM authentication tag (The tag

0 commit comments

Comments
 (0)