From fa884d72d74f3a214578232f164dc31fd46b2290 Mon Sep 17 00:00:00 2001 From: Alexander PapaTutuWawa Date: Sun, 21 Feb 2021 22:23:26 +0100 Subject: [PATCH] mod_mix: Fix leaving channels --- mod_mix/mod_mix.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mod_mix/mod_mix.lua b/mod_mix/mod_mix.lua index 6295bdd..3b28387 100644 --- a/mod_mix/mod_mix.lua +++ b/mod_mix/mod_mix.lua @@ -119,10 +119,10 @@ local function publish_participant(service, channel, spid, participant) -- Publish a new participant on the service -- NOTE: This function has be to called *after* the new participant -- has been added to the channel.participants attay - service:set_node_config("urn:xmpp:mix:nodes:participants", + service:set_node_config(mix_node_participants, true, { ["max_items"] = #channel.participants }); - service:publish("urn:xmpp:mix:nodes:participants", + service:publish(mix_node_participants, true, spid, st.stanza("item", { id = spid, xmlns = "http://jabber.org/protocol/pubsub" }) @@ -363,7 +363,7 @@ module:hook("iq-set/bare/"..mix_core_xmlns..":leave", function(event) -- Remove the user as a participant by... -- Unsubscribing - local srv = pep.get_pep_service(channel.jid); + local srv = pep.get_pep_service(jid.node(channel.jid)); for _, node in pairs(channel.subscriptions[from]) do srv:set_affiliation(node, true, from, "outcast"); srv:remove_subscription(node, true, from); @@ -371,7 +371,10 @@ module:hook("iq-set/bare/"..mix_core_xmlns..":leave", function(event) end channel.subscriptions[from] = nil; -- Retracting the participation - srv:retract("urn:xmpp:mix:nodes:participants", true, channel:get_spid(from), true); + local spid = channel:get_spid(from); + local notifier = st.stanza("retract", { id = spid }); + -- TODO: Maybe error handling + srv:retract(mix_node_participants, true, spid, notifier); -- Removing the user table.remove(channel.participants, j); channel:save_state();