mod_privilege: Fix IQ privileges advertising for multiple namespaces
authornicoco <nicoco@nicoco.fr>
Fri, 22 Mar 2024 11:02:04 +0100
changeset 5877 a88c43de648c
parent 5876 8aec430ba205
child 5878 f8b9095f7862
mod_privilege: Fix IQ privileges advertising for multiple namespaces Before this fix, the namespaces element were wrongly nested.
mod_privilege/mod_privilege.lua
--- a/mod_privilege/mod_privilege.lua	Thu Mar 21 19:44:27 2024 +0100
+++ b/mod_privilege/mod_privilege.lua	Fri Mar 22 11:02:04 2024 +0100
@@ -69,7 +69,7 @@
     end
     local iq_perm = perms["iq"]
     if iq_perm ~= nil then
-        message:tag("perm", {access="iq"})
+        local perm_el = st.stanza("perm", {access="iq"})
         for namespace, ns_perm in pairs(iq_perm) do
                 local perm_type
                 if ns_perm.set and ns_perm.get then
@@ -81,8 +81,9 @@
                 else
                     perm_type = nil
                 end
-                message:tag("namespace", {ns=namespace, type=perm_type})
+                perm_el:tag("namespace", {ns=namespace, type=perm_type}):up()
         end
+        message:add_child(perm_el)
     end
     session.send(message)
 end