borogove/sdk

created pr with 135.1 on 2026-08-12T17:55:41Z · by 3c31bc8c
cmds
checkout latest patchset:
ssh pr.pico.sh print 135 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 135.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 135

Patchset 135.1 on 2026-08-12T17:55:41Z · commit 0fb786e

Don't create a channel if there is existing chat
Eric Roberts 2026-08-12T17:52:53Z
Bit of weirdness here, if getChat returns something that is not a channel, then
currently we just leave it. Maybe we should revisit this in the future.
Semantic diff summary
0 added, 0 modified, 0 signature changed, 0 removed across 0 analyzed files (2 files skipped: unsupported file type)
+10 -4 borogove/Client.hx #
......@@ -2061,10 +2061,16 @@ class Client extends EventEmitter {
20612061 } else {
20622062 final cachedCaps = capsRepo.add(resultCaps);
20632063 if (cachedCaps.isChannel(jid)) {
2064- final chat = new Channel(this, this.stream, this.persistence, jid, uiState, false, false, null, cachedCaps);
2065- chat.setupNotifications();
2066- chats.unshift(chat);
2067- if (inSync && sendAvailable) chat.selfPing(false);
2064+ final existing = getChat(jid);
2065+ final chat = if (existing == null) {
2066+ final channel = new Channel(this, this.stream, this.persistence, jid, uiState, false, false, null, cachedCaps);
2067+ channel.setupNotifications();
2068+ if (inSync && sendAvailable) channel.selfPing(false);
2069+ chats.unshift(channel);
2070+ channel;
2071+ } else {
2072+ existing;
2073+ }
20682074 handleChat(chat);
20692075 persistence.storeChats(accountId(), [chat]);
20702076 this.trigger("chats/update", [chat]);
+26 -0 test/TestClient.hx #
......@@ -761,6 +761,32 @@ class TestClient extends utest.Test {
761761 );
762762 }
763763
764+ public function testStartChatWith(async: Async) {
765+ final persistence = new Dummy();
766+ final client = new Client("test@example.com", persistence);
767+ final chat = new borogove.Chat.Channel(client, client.stream, persistence, "room@example.com");
768+ client.chats.push(chat);
769+
770+ client.stream.on("sendStanza", (stanza: Stanza) -> {
771+ if (stanza.name == "iq" && stanza.attr.get("type") == "get") {
772+ final stanza = Stanza.parse('<iq from="room@example.com" type="result" id="${stanza.attr.get("id")}" xmlns="jabber:client">
773+ <query xmlns="http://jabber.org/protocol/disco#info">
774+ <identity category="conference" type="text" name="Cool chatroom" />
775+ <feature var="http://jabber.org/protocol/muc" />
776+ </query>
777+ </iq>');
778+
779+ client.stream.onStanza(stanza);
780+ }
781+ return EventHandled;
782+ });
783+
784+ client.startChatWith("room@example.com", _->Open, _->{
785+ Assert.equals(1, client.chats.length);
786+ async.done();
787+ });
788+ }
789+
764790 #if js
765791 public function testPreferOMEMO() {
766792 final persistence = new Dummy();
Back to top