| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-11-09 19:40:59 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-11-16 14:55:03 UTC |
| parent | bab968ed394359c3eb04d5eb15412247e157ac85 |
| borogove/Message.hx | +5 | -2 |
| test/TestChatMessage.hx | +25 | -0 |
diff --git a/borogove/Message.hx b/borogove/Message.hx index 369f28e..6a9b184 100644 --- a/borogove/Message.hx +++ b/borogove/Message.hx @@ -192,8 +192,11 @@ class Message { trace("No support for addressing to non-jid", address); return new Message(msg.chatId(), msg.senderId, msg.threadId, UnknownMessageStanza(stanza), encryptionInfo); } else if (address.attr.get("type") == "to" || address.attr.get("type") == "cc") { - recipients[JID.parse(jid).asBare().asString()] = true; - if (!anyExtendedReplyTo) replyTo[JID.parse(jid).asString()] = true; // reply all + final addressJid = JID.parse(jid); + recipients[addressJid.asBare().asString()] = true; + if (!anyExtendedReplyTo && !(msg.direction == MessageReceived && addressJid.asBare().equals(localJidBare))) { + replyTo[addressJid.asString()] = true; // reply all + } } else if (address.attr.get("type") == "replyto" || address.attr.get("type") == "replyroom") { if (!anyExtendedReplyTo) { replyTo.clear(); diff --git a/test/TestChatMessage.hx b/test/TestChatMessage.hx index 87b5436..d681ef5 100644 --- a/test/TestChatMessage.hx +++ b/test/TestChatMessage.hx @@ -259,7 +259,9 @@ class TestChatMessage extends utest.Test { final msg = Message.fromStanza(stanza, JID.parse("me@example.com")); switch (msg.parsed) { case ChatMessageStanza(m): + Assert.equals("alice@example.com", m.chatId()); Assert.same(["alice@example.com", "me@example.com"], m.recipients.map(r -> r.asBare().asString())); + Assert.same(["alice@example.com"], m.replyTo.map(r -> r.asBare().asString())); default: Assert.fail("Expected ChatMessageStanza"); } @@ -363,6 +365,29 @@ class TestChatMessage extends utest.Test { } } + public function testExtendedMultiDMChatIdNeverIncludesSelf() { + final builder = new borogove.ChatMessageBuilder(); + builder.localId = "extended-multi-1"; + builder.direction = MessageSent; + builder.from = JID.parse("alice@example.com"); + builder.senderId = "alice@example.com"; + builder.to = JID.parse("bob@example.com"); + builder.recipients = [JID.parse("bob@example.com"), JID.parse("carol@example.com")]; + builder.replyTo = [JID.parse("alice@example.com")]; + builder.setBody(borogove.Html.text("hi")); + + final stanza = builder.build().asStanza(); + Assert.equals("bob@example.com\ncarol@example.com", Message.fromStanza(stanza, JID.parse("alice@example.com")).chatId); + + final toBob = stanza.clone(); + toBob.attr.set("to", "bob@example.com"); + Assert.equals("alice@example.com\ncarol@example.com", Message.fromStanza(toBob, JID.parse("bob@example.com")).chatId); + + final toCarol = stanza.clone(); + toCarol.attr.set("to", "carol@example.com"); + Assert.equals("alice@example.com\nbob@example.com", Message.fromStanza(toCarol, JID.parse("carol@example.com")).chatId); + } + public function testReactionFallbackSkipsNestedQuotes() { // Build a parent message that itself contains a quote and regular text final parentBuilder = new borogove.ChatMessageBuilder();