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 | f19598cd27986c19ff4fb84a4943b74def2e53e9 (patch) | |
tree | 16d58f332fd34f104af99b00ededc172164f0c87 /plugins/mod_pep.lua | |
parent | 72b502bed309c90247cf578caf86791ad251b949 (diff) | |
download | prosody-f19598cd27986c19ff4fb84a4943b74def2e53e9.tar.gz prosody-f19598cd27986c19ff4fb84a4943b74def2e53e9.zip |
mod_pep: Fire an event when an item is published
Diffstat (limited to 'plugins/mod_pep.lua')
-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 |