borogove

created pr with borogove/multi-dm.1 on 2026-11-09T19:47:55Z · by 9e834e0d
added borogove/multi-dm.2 on 2026-11-10T19:08:22Z · by 9e834e0d
1: 0ef2769 = 1: 41e89c8 Use to for chatId if not in recipients
2: 90e5a6a = 2: c323e3d clone should clone attributes
3: d86ea28 = 3: a1199ae Actually send to all recipients
4: 1c1061f ! 4: 94bf87d Never add self as counterpart
5: 9c8aa41 = 5: 32b9fad Extended addressing for sent messages specifies all recipients
6: 2da9124 = 6: ce4d9e1 Always add all recipients to outbound message
7: e7db006 = 7: 350343e Use a shared helper for adding extended addressing
8: 4530ece = 8: 40f662a Add startMultiChat to create multiDMs
9: 6810ba9 = 9: 8043c53 Never include ourselves in incoming chat ids
-: ------- > 10: 68e7246 Cannot MAM or bookmark a multiDM
cmds
checkout latest patchset:
ssh pr.pico.sh pull borogove:multi-dm | git am -3
checkout specific patchset revision:
ssh pr.pico.sh pull borogove:multi-dm [rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh borogove:multi-dm
add comment to patch request:
ssh pr.pico.sh comment borogove:multi-dm "lgtm!"
+3 -3 borogove/Chat.hx #
......@@ -1400,16 +1400,16 @@ class DirectChat extends Chat {
14001400 if (e2eePreference == Default) e2eePreference = client.outgoingE2EEPreference[0];
14011401 #if NO_OMEMO
14021402 if (e2eePreference != NoE2EE) throw "Selected E2EE preference unsupported";
1403- return Promise.resolve(stanza);
1403+ return Promise.resolve(clone);
14041404 #else
14051405 switch (e2eePreference) {
14061406 case OMEMO:
14071407 // As written this falls back to NoE2EE if allowed
1408- return client.omemo.encryptMessage([JID.parse(counterpart)], stanza).then((encryptedStanza) -> {
1408+ return client.omemo.encryptMessage([JID.parse(counterpart)], clone).then((encryptedStanza) -> {
14091409 return Promise.resolve(encryptedStanza);
14101410 });
14111411 case NoE2EE:
1412- return Promise.resolve(stanza);
1412+ return Promise.resolve(clone);
14131413 case Default:
14141414 throw "Impossible";
14151415 }
+51 -0 test/TestChat.hx #
......@@ -1230,6 +1230,57 @@ class TestChat extends utest.Test {
12301230 chat.sendMessage(builder, borogove.Chat.OutgoingE2EEPreference.OMEMO);
12311231 }
12321232 #end
1233+
1234+ public function testSendMessageExtendedMultiDMSendsToEachParticipant(async: Async) {
1235+ final persistence = new RecordingPersistence();
1236+ final client = new Client("me@example.com", persistence);
1237+ final chat = client.getDirectChat("bob@example.com\ncarol@example.com");
1238+ final sent: Array<Stanza> = [];
1239+
1240+ client.stream.on("sendStanza", (stanza: Stanza) -> {
1241+ if (stanza.name != "message" || stanza.getChildText("body") != "hello") return EventUnhandled;
1242+ sent.push(stanza);
1243+ if (sent.length < 2) return EventUnhandled;
1244+
1245+ final tos = sent.map(s -> s.attr.get("to"));
1246+ tos.sort(Reflect.compare);
1247+ Assert.same(["bob@example.com", "carol@example.com"], tos);
1248+ for (s in sent) {
1249+ final addresses = s.getChild("addresses", "http://jabber.org/protocol/address");
1250+ Assert.notNull(addresses);
1251+ if (addresses != null) {
1252+ final jids = addresses.allTags("address").map(a -> a.attr.get("jid"));
1253+ jids.sort(Reflect.compare);
1254+ Assert.same(["bob@example.com", "carol@example.com"], jids);
1255+ }
1256+ }
1257+
1258+ Assert.equals(1, persistence.storedMessages.length);
1259+ if (persistence.storedMessages.length > 0) {
1260+ final stored = persistence.storedMessages[0];
1261+ Assert.equals(chat.chatId, stored.chatId());
1262+ Assert.equals("bob@example.com", stored.to?.asString());
1263+ Assert.same(["bob@example.com", "carol@example.com"], stored.recipients.map(r -> r.asBare().asString()));
1264+ }
1265+ async.done();
1266+ return EventHandled;
1267+ });
1268+
1269+ final builder = new ChatMessageBuilder();
1270+ builder.text = "hello";
1271+ chat.sendMessage(builder, borogove.Chat.OutgoingE2EEPreference.NoE2EE);
1272+ }
1273+
1274+}
1275+
1276+@:access(borogove)
1277+class RecordingPersistence extends Dummy {
1278+ public var storedMessages: Array<borogove.ChatMessage> = [];
1279+
1280+ override public function storeMessages(accountId: String, messages: Array<borogove.ChatMessage>) {
1281+ storedMessages = storedMessages.concat(messages);
1282+ return Promise.resolve(messages);
1283+ }
12331284 }
12341285
12351286 @:access(borogove)
Back to top