git » sdk » commit 5cfcc14

Put AvailableChat on a Participant where possible

author Stephen Paul Weber
2026-03-16 20:10:25 UTC
committer Stephen Paul Weber
2026-03-16 20:10:25 UTC
parent d410689418230007d59597f93379fac9cb477f64

Put AvailableChat on a Participant where possible

borogove/Chat.hx +25 -3
borogove/Participant.hx +4 -1

diff --git a/borogove/Chat.hx b/borogove/Chat.hx
index f3f7814..b4e8418 100644
--- a/borogove/Chat.hx
+++ b/borogove/Chat.hx
@@ -973,7 +973,14 @@ class DirectChat extends Chat {
 	@HaxeCBridge.noemit // on superclass as abstract
 	public function getParticipantDetails(participantId:String): Participant {
 		final chat = client.getDirectChat(participantId);
-		return new Participant(chat.getDisplayName(), chat.getPhoto(), chat.getPlaceholder(), chat.chatId == client.accountId(), JID.parse(participantId));
+		return new Participant(
+			chat.getDisplayName(),
+			chat.getPhoto(),
+			chat.getPlaceholder(),
+			chat.chatId == client.accountId(),
+			JID.parse(participantId),
+			new AvailableChat(participantId, chat.getDisplayName(), "", new Caps("", [], [], []))
+		);
 	}
 
 	@HaxeCBridge.noemit // on superclass as abstract
@@ -1640,12 +1647,27 @@ trace("XYZZY no MUC avatar locally matching so fetch vcard", chatId, avatarSha1H
 	public function getParticipantDetails(participantId:String): Participant {
 		if (participantId == getFullJid().asString()) {
 			final chat = client.getDirectChat(client.accountId(), false);
-			return new Participant(client.displayName(), chat.getPhoto(), chat.getPlaceholder(), true, JID.parse(chat.chatId));
+			return new Participant(
+				client.displayName(),
+				chat.getPhoto(),
+				chat.getPlaceholder(),
+				true,
+				JID.parse(chat.chatId),
+				new AvailableChat(chat.chatId, chat.getDisplayName(), "", new Caps("", [], [], []))
+			);
 		} else {
 			final jid = JID.parse(participantId);
 			final nick = jid.resource;
 			final placeholderUri = Color.defaultPhoto(participantId, nick == null ? " " : nick.charAt(0));
-			return new Participant(nick ?? "", presence[nick]?.avatarHash?.toUri(), placeholderUri, false, jid);
+			final ppresence = presence[nick];
+			return new Participant(
+				nick ?? "",
+				ppresence?.avatarHash?.toUri(),
+				placeholderUri,
+				false,
+				jid,
+				ppresence?.mucUser?.jid == null ? null : new AvailableChat(ppresence.mucUser.jid.asBare().asString(), nick ?? "", "", new Caps("", [], [], []))
+			);
 		}
 	}
 
diff --git a/borogove/Participant.hx b/borogove/Participant.hx
index a5b52fc..da405c0 100644
--- a/borogove/Participant.hx
+++ b/borogove/Participant.hx
@@ -2,6 +2,7 @@ package borogove;
 
 import thenshim.Promise;
 
+import borogove.Chat;
 import borogove.queries.PubsubGet;
 
 #if cpp
@@ -19,14 +20,16 @@ class Participant {
 	public final photoUri: Null<String>;
 	public final placeholderUri: String;
 	public final isSelf: Bool;
+	public final chat: Null<AvailableChat>;
 	private final jid: JID;
 
 	@:allow(borogove)
-	private function new(displayName: String, photoUri: Null<String>, placeholderUri: String, isSelf: Bool, jid: JID) {
+	private function new(displayName: String, photoUri: Null<String>, placeholderUri: String, isSelf: Bool, jid: JID, chat: Null<AvailableChat>) {
 		this.displayName = displayName;
 		this.photoUri = photoUri;
 		this.placeholderUri = placeholderUri;
 		this.isSelf = isSelf;
+		this.chat = chat;
 		this.jid = jid;
 	}