git » sdk » commit 19edc78

Support xmpp uri in link-alternate header

author Stephen Paul Weber
2025-11-06 05:21:22 UTC
committer Stephen Paul Weber
2025-11-06 05:21:22 UTC
parent 2446c7633b313b78ef839d6d163833812d8e72ba

Support xmpp uri in link-alternate header

Just like conversations we're a bit lax here and don't actually validate
format, just extract any xmpp URI we can find and try it.

borogove/Client.hx +20 -0

diff --git a/borogove/Client.hx b/borogove/Client.hx
index 7cfafce..9503dec 100644
--- a/borogove/Client.hx
+++ b/borogove/Client.hx
@@ -929,6 +929,26 @@ class Client extends EventEmitter {
 		if (jid.isValid()) {
 			checkAndAdd(jid, true);
 		}
+
+		if (StringTools.startsWith(query, "https://")) {
+			tink.http.Client.fetch(query, {
+				method: HEAD
+			}).all()
+				.handle(function(o) switch o {
+					case Success(res):
+						final regex = ~/<xmpp:([^>]+)>/;
+						for (link in res.header.get("link")) {
+							if (regex.match(link)) {
+								final parts = regex.matched(1).split("?");
+								final jid = JID.parse(StringTools.urlDecode(parts[0]));
+								if (jid.isValid()) checkAndAdd(jid, true);
+							}
+						}
+					case Failure(e):
+						trace("findAvailable request failed", e);
+				});
+		}
+
 		for (chat in chats) {
 			if (chat.chatId != jid.asBare().asString()) {
 				if (chat.chatId.contains(query.toLowerCase()) || chat.getDisplayName().toLowerCase().contains(query.toLowerCase())) {