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!"
+5 -1 borogove/ChatMessage.hx #
......@@ -502,7 +502,11 @@ class ChatMessage {
502502 if (isIncoming()) {
503503 return replyTo.map((r) -> r.asBare().asString()).join("\n");
504504 } else {
505- return recipients.map((r) -> r.asString()).join("\n");
505+ // If sent to a non-recipient, use that as the chat id
506+ // e.g. a multiDM sent to 1,2,3@cheogram.com
507+ final bareTo = to.asBare();
508+ if (!recipients.exists((r) -> r.asBare().equals(bareTo))) return bareTo.asString();
509+ return recipients.map((r) -> r.asBare().asString()).join("\n");
506510 }
507511 }
508512
+6 -1 borogove/ChatMessageBuilder.hx #
......@@ -379,7 +379,12 @@ class ChatMessageBuilder {
379379 if (isIncoming()) {
380380 return replyTo.map((r) -> r.asBare().asString()).join("\n");
381381 } else {
382- return recipients.map((r) -> r.asString()).join("\n");
382+ final toJid = to;
383+ if (toJid != null) {
384+ final bareTo = toJid.asBare();
385+ if (!recipients.exists((r) -> r.asBare().equals(bareTo))) return bareTo.asString();
386+ }
387+ return recipients.map((r) -> r.asBare().asString()).join("\n");
383388 }
384389 }
385390
+38 -0 test/TestChatMessageBuilder.hx #
......@@ -6,6 +6,7 @@ import utest.Async;
66 import borogove.ChatMessageBuilder;
77 import borogove.Html;
88 import borogove.JID;
9+import borogove.Message;
910
1011 @:access(borogove)
1112 class TestChatMessageBuilder extends utest.Test {
......@@ -125,4 +126,41 @@ class TestChatMessageBuilder extends utest.Test {
125126 final stanza = msg.asStanza();
126127 Assert.isNull(stanza.getChild("request", "urn:xmpp:receipts"));
127128 }
129+
130+ public function testChatIdOutgoingUsesToWhenNotInRecipients() {
131+ final builder = new ChatMessageBuilder();
132+ builder.direction = MessageSent;
133+ builder.from = JID.parse("me@example.com");
134+ builder.to = JID.parse("multi@example.com");
135+ builder.recipients = [JID.parse("bob@example.com"), JID.parse("carol@example.com")];
136+ builder.replyTo = [JID.parse("me@example.com")];
137+ Assert.equals("multi@example.com", builder.chatId());
138+ }
139+
140+ public function testChatIdOutgoingUsesBareTo() {
141+ final builder = new ChatMessageBuilder();
142+ builder.direction = MessageSent;
143+ builder.from = JID.parse("me@example.com");
144+ builder.to = JID.parse("multi@example.com/device");
145+ builder.recipients = [JID.parse("bob@example.com"), JID.parse("carol@example.com")];
146+ Assert.equals("multi@example.com", builder.chatId());
147+ }
148+
149+ public function testChatIdOutgoingUsesRecipientsWhenToIsAmongThem() {
150+ final builder = new ChatMessageBuilder();
151+ builder.direction = MessageSent;
152+ builder.from = JID.parse("me@example.com");
153+ builder.to = JID.parse("bob@example.com");
154+ builder.recipients = [JID.parse("bob@example.com"), JID.parse("carol@example.com")];
155+ Assert.equals("bob@example.com\ncarol@example.com", builder.chatId());
156+ }
157+
158+ public function testChatIdOutgoingSingleRecipient() {
159+ final builder = new ChatMessageBuilder();
160+ builder.direction = MessageSent;
161+ builder.from = JID.parse("me@example.com");
162+ builder.to = JID.parse("bob@example.com");
163+ builder.recipients = [JID.parse("bob@example.com")];
164+ Assert.equals("bob@example.com", builder.chatId());
165+ }
128166 }
Back to top