diff options
author | Kim Alvefur <zash@zash.se> | 2014-12-20 21:34:59 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2014-12-20 21:34:59 +0100 |
commit | cbf2c1e2c4c26220968cdf7ce6ee1130ba379847 (patch) | |
tree | 16d58f332fd34f104af99b00ededc172164f0c87 | |
parent | 7aa032e7652834c2feac726ed1276c941e1dfb3f (diff) | |
download | prosody-cbf2c1e2c4c26220968cdf7ce6ee1130ba379847.tar.gz prosody-cbf2c1e2c4c26220968cdf7ce6ee1130ba379847.zip |
mod_pep: Fire an event when an item is published
-rw-r--r-- | plugins/mod_pep.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index 752cd28c..a6916d1f 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -41,7 +41,8 @@ local function subscription_presence(user_bare, recipient) return is_contact_subscribed(username, host, recipient_bare); end -local function publish(session, node, id, item) +module:hook("pep-publish-item", function (event) + local session, node, id, item = event.session, event.node, event.id, event.item; item.attr.xmlns = nil; local disable = #item.tags ~= 1 or #item.tags[1] == 0; if #item.tags == 0 then item.name = "retract"; end @@ -72,7 +73,8 @@ local function publish(session, node, id, item) core_post_stanza(session, stanza); end end -end +end); + local function publish_all(user, recipient, session) local d = data[user]; local notify = recipients[user] and recipients[user][recipient]; @@ -172,7 +174,9 @@ module:hook("iq/bare/http://jabber.org/protocol/pubsub:pubsub", function(event) local id = payload.attr.id or "1"; payload.attr.id = id; session.send(st.reply(stanza)); - publish(session, node, id, st.clone(payload)); + module:fire_event("pep-publish-item", { + node = node, actor = session.jid, id = id, session = session, item = st.clone(payload); + }); return true; end end |