Diff

plugins/disco.lua @ 473:b2198cd64c5a

disco: Add support for extended disco forms
author Matthew Wild <mwild1@gmail.com>
date Fri, 17 Mar 2023 11:12:01 +0000
parent 429:46897d7769c3
child 474:fca0c7672148
line wrap: on
line diff
--- a/plugins/disco.lua	Fri Mar 17 11:07:02 2023 +0000
+++ b/plugins/disco.lua	Fri Mar 17 11:12:01 2023 +0000
@@ -203,7 +203,7 @@
 				return callback(nil, result:get_error());
 			end
 
-			local identities, features = {}, {};
+			local identities, features, extended = {}, {}, {};
 
 			for tag in result:get_child("query", xmlns_disco_info):childtags() do
 				if tag.name == "identity" then
@@ -213,6 +213,13 @@
 				end
 			end
 
+			for tag in result:get_child("query", xmlns_disco_info):childtags("x", "jabber:x:data") do
+				local form_type_field = tag:get_child_with_attr("field", nil, "var", "FORM_TYPE");
+				local form_type = form_type_field and form_type_field:get_child_text("value");
+				if form_type then
+					extended[form_type] = tag;
+				end
+			end
 
 			if not self.disco.cache[jid] then
 				self.disco.cache[jid] = { nodes = {} };
@@ -224,9 +231,11 @@
 				end
 				self.disco.cache[jid].nodes[node].identities = identities;
 				self.disco.cache[jid].nodes[node].features = features;
+				self.disco.cache[jid].nodes[node].extended = extended;
 			else
 				self.disco.cache[jid].identities = identities;
 				self.disco.cache[jid].features = features;
+				self.disco.cache[jid].extended = extended;
 			end
 			return callback(self.disco.cache[jid]);
 		end);