Mercurial > prosody-hg
comparison plugins/mod_pep.lua @ 7453:b1efeee55972
mod_pep: Include the bare user jid in event
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 09 Jun 2016 10:30:33 +0200 |
| parents | abff7543b79c |
| children | d10b4bfb20c5 |
comparison
equal
deleted
inserted
replaced
| 7449:6943b1dd4e3d | 7453:b1efeee55972 |
|---|---|
| 45 local username, host = jid_split(user_bare); | 45 local username, host = jid_split(user_bare); |
| 46 return is_contact_subscribed(username, host, recipient_bare); | 46 return is_contact_subscribed(username, host, recipient_bare); |
| 47 end | 47 end |
| 48 | 48 |
| 49 module:hook("pep-publish-item", function (event) | 49 module:hook("pep-publish-item", function (event) |
| 50 local session, node, id, item = event.session, event.node, event.id, event.item; | 50 local session, bare, node, id, item = event.session, event.user, event.node, event.id, event.item; |
| 51 item.attr.xmlns = nil; | 51 item.attr.xmlns = nil; |
| 52 local disable = #item.tags ~= 1 or #item.tags[1] == 0; | 52 local disable = #item.tags ~= 1 or #item.tags[1] == 0; |
| 53 if #item.tags == 0 then item.name = "retract"; end | 53 if #item.tags == 0 then item.name = "retract"; end |
| 54 local bare = session.username..'@'..session.host; | |
| 55 local stanza = st.message({from=bare, type='headline'}) | 54 local stanza = st.message({from=bare, type='headline'}) |
| 56 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) | 55 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) |
| 57 :tag('items', {node=node}) | 56 :tag('items', {node=node}) |
| 58 :add_child(item) | 57 :add_child(item) |
| 59 :up() | 58 :up() |
| 181 if payload and payload.name == "item" then -- <item> | 180 if payload and payload.name == "item" then -- <item> |
| 182 local id = payload.attr.id or "1"; | 181 local id = payload.attr.id or "1"; |
| 183 payload.attr.id = id; | 182 payload.attr.id = id; |
| 184 session.send(st.reply(stanza)); | 183 session.send(st.reply(stanza)); |
| 185 module:fire_event("pep-publish-item", { | 184 module:fire_event("pep-publish-item", { |
| 186 node = node, actor = session.jid, id = id, session = session, item = st.clone(payload); | 185 node = node, user = jid_bare(session.jid), actor = session.jid, id = id, session = session, item = st.clone(payload); |
| 187 }); | 186 }); |
| 188 return true; | 187 return true; |
| 189 end | 188 end |
| 190 end | 189 end |
| 191 elseif stanza.attr.type == 'get' then | 190 elseif stanza.attr.type == 'get' then |
