| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-05-27 17:23:10 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-05-27 17:23:10 UTC |
| parent | f94778747875b8a960ebace5a307118bbfd9d853 |
| borogove/Chat.hx | +8 | -0 |
| test/TestChat.hx | +16 | -0 |
diff --git a/borogove/Chat.hx b/borogove/Chat.hx index d6cd173..456ab18 100644 --- a/borogove/Chat.hx +++ b/borogove/Chat.hx @@ -749,6 +749,14 @@ abstract class Chat extends EventEmitter { for (resource => caps in getCaps()) { if (caps.features?.contains("urn:xmpp:jingle:apps:rtp:audio") ?? false) return true; } + + final jid = JID.parse(chatId); + if (jid != null && !jid.isDomain()) { + final domainChat = client.getChat(jid.domain); + if (domainChat != null && Caps.withIdentity(domainChat.getCaps(), "gateway", "pstn").hasNext()) { + return true; + } + } #end return false; } diff --git a/test/TestChat.hx b/test/TestChat.hx index 1e3882b..cdb4a92 100644 --- a/test/TestChat.hx +++ b/test/TestChat.hx @@ -490,6 +490,22 @@ class TestChat extends utest.Test { async.done(); }); } + + public function testCanAudioCallPSTN() { + final persistence = new Dummy(); + final client = new Client("test@example.com", persistence); + + final domain = "pstn.example.com"; + final domainChat = client.getDirectChat(domain); + + final caps = new borogove.Caps("", [new Identity("gateway", "pstn", "PSTN Gateway")], [], []); + final presence = new borogove.Presence(caps, null, null); + domainChat.presence.set("", presence); + client.capsRepo.add(caps); + + final chat = client.getDirectChat("+123456789@" + domain); + Assert.isTrue(chat.canAudioCall()); + } } @:access(borogove)