X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=plugins%2Fmod_pep.lua;h=28c312944fbf0e268e8c3bf5c04d7ec3d714c4b6;hb=c43ea656e3ccdc159ba27904fe06a9226952e817;hp=63063976c60654181f6c7b7a093aa40075867866;hpb=ac411fd11d1367a8687a70e7f33ac5dcd1bd9dc0;p=prosody.git diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index 63063976..28c31294 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -145,6 +145,16 @@ module:hook("presence/bare", function(event) end elseif t == "unavailable" then if recipients[user] then recipients[user][stanza.attr.from] = nil; end + elseif not self and t == "unsubscribe" then + local from = jid_bare(stanza.attr.from); + local subscriptions = recipients[user]; + if subscriptions then + for subscriber in pairs(subscriptions) do + if jid_bare(subscriber) == from then + recipients[user][subscriber] = nil; + end + end + end end end, 10); @@ -235,15 +245,15 @@ module:hook("iq-result/bare/disco", function(event) end hash_map[ver] = notify; -- update hash map if self then - for jid, item in pairs(origin.roster) do -- for all interested contacts + for jid, item in pairs(session.roster) do -- for all interested contacts if item.subscription == "both" or item.subscription == "from" then if not recipients[jid] then recipients[jid] = {}; end recipients[jid][contact] = notify; + publish_all(jid, contact, session); end end - else - recipients[user][contact] = notify; -- set recipient's data to calculated data end + recipients[user][contact] = notify; -- set recipient's data to calculated data -- send messages to recipient publish_all(user, contact, session); end