Software /
code /
prosody
Comparison
plugins/mod_pep.lua @ 1619:ae3250783db2
mod_pep: Added support for pubsub item retraction
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Wed, 29 Jul 2009 17:57:24 +0500 |
parent | 1522:569d58d21612 |
child | 1625:b6645fe7d89f |
comparison
equal
deleted
inserted
replaced
1617:c6e175a0d83b | 1619:ae3250783db2 |
---|---|
28 module:add_identity("pubsub", "pep"); | 28 module:add_identity("pubsub", "pep"); |
29 module:add_feature("http://jabber.org/protocol/pubsub#publish"); | 29 module:add_feature("http://jabber.org/protocol/pubsub#publish"); |
30 | 30 |
31 local function publish(session, node, item) | 31 local function publish(session, node, item) |
32 local disable = #item.tags ~= 1 or #item.tags[1].tags == 0; | 32 local disable = #item.tags ~= 1 or #item.tags[1].tags == 0; |
33 if #item.tags == 0 then item.name = "retract"; end | |
33 local bare = session.username..'@'..session.host; | 34 local bare = session.username..'@'..session.host; |
34 local stanza = st.message({from=bare, type='headline'}) | 35 local stanza = st.message({from=bare, type='headline'}) |
35 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) | 36 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) |
36 :tag('items', {node=node}) | 37 :tag('items', {node=node}) |
37 :add_child(item) | 38 :add_child(item) |
126 local session, stanza = event.origin, event.stanza; | 127 local session, stanza = event.origin, event.stanza; |
127 if stanza.attr.type == 'set' and (not stanza.attr.to or jid_bare(stanza.attr.from) == stanza.attr.to) then | 128 if stanza.attr.type == 'set' and (not stanza.attr.to or jid_bare(stanza.attr.from) == stanza.attr.to) then |
128 local payload = stanza.tags[1]; | 129 local payload = stanza.tags[1]; |
129 if payload.name == 'pubsub' then -- <pubsub xmlns='http://jabber.org/protocol/pubsub'> | 130 if payload.name == 'pubsub' then -- <pubsub xmlns='http://jabber.org/protocol/pubsub'> |
130 payload = payload.tags[1]; | 131 payload = payload.tags[1]; |
131 if payload and payload.name == 'publish' and payload.attr.node then -- <publish node='http://jabber.org/protocol/tune'> | 132 if payload and (payload.name == 'publish' or payload.name == 'retract') and payload.attr.node then -- <publish node='http://jabber.org/protocol/tune'> |
132 local node = payload.attr.node; | 133 local node = payload.attr.node; |
133 payload = payload.tags[1]; | 134 payload = payload.tags[1]; |
134 if payload then -- <item> | 135 if payload then -- <item> |
135 publish(session, node, payload); | 136 publish(session, node, payload); |
136 return true; | 137 return true; |