mod_mix: Fix leaving channels
This commit is contained in:
parent
b0aca926fe
commit
fa884d72d7
@ -119,10 +119,10 @@ local function publish_participant(service, channel, spid, participant)
|
|||||||
-- Publish a new participant on the service
|
-- Publish a new participant on the service
|
||||||
-- NOTE: This function has be to called *after* the new participant
|
-- NOTE: This function has be to called *after* the new participant
|
||||||
-- has been added to the channel.participants attay
|
-- 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,
|
true,
|
||||||
{ ["max_items"] = #channel.participants });
|
{ ["max_items"] = #channel.participants });
|
||||||
service:publish("urn:xmpp:mix:nodes:participants",
|
service:publish(mix_node_participants,
|
||||||
true,
|
true,
|
||||||
spid,
|
spid,
|
||||||
st.stanza("item", { id = spid, xmlns = "http://jabber.org/protocol/pubsub" })
|
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...
|
-- Remove the user as a participant by...
|
||||||
-- Unsubscribing
|
-- 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
|
for _, node in pairs(channel.subscriptions[from]) do
|
||||||
srv:set_affiliation(node, true, from, "outcast");
|
srv:set_affiliation(node, true, from, "outcast");
|
||||||
srv:remove_subscription(node, true, from);
|
srv:remove_subscription(node, true, from);
|
||||||
@ -371,7 +371,10 @@ module:hook("iq-set/bare/"..mix_core_xmlns..":leave", function(event)
|
|||||||
end
|
end
|
||||||
channel.subscriptions[from] = nil;
|
channel.subscriptions[from] = nil;
|
||||||
-- Retracting the participation
|
-- 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
|
-- Removing the user
|
||||||
table.remove(channel.participants, j);
|
table.remove(channel.participants, j);
|
||||||
channel:save_state();
|
channel:save_state();
|
||||||
|
Loading…
Reference in New Issue
Block a user