15 module:add_identity("pubsub", "pep"); |
15 module:add_identity("pubsub", "pep"); |
16 module:add_feature("http://jabber.org/protocol/pubsub#publish"); |
16 module:add_feature("http://jabber.org/protocol/pubsub#publish"); |
17 |
17 |
18 local function publish(session, node, item) |
18 local function publish(session, node, item) |
19 local disable = #item.tags ~= 1 or #item.tags[1].tags == 0; |
19 local disable = #item.tags ~= 1 or #item.tags[1].tags == 0; |
20 local stanza = st.message({from=session.full_jid, type='headline'}) |
20 local bare = session.username..'@'..session.host; |
|
21 local stanza = st.message({from=bare, type='headline'}) |
21 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) |
22 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) |
22 :tag('items', {node=node}) |
23 :tag('items', {node=node}) |
23 :add_child(item) |
24 :add_child(item) |
24 :up() |
25 :up() |
25 :up(); |
26 :up(); |
26 |
27 |
27 local bare = session.username..'@'..session.host; |
|
28 -- store for the future |
28 -- store for the future |
29 local user_data = data[bare]; |
29 local user_data = data[bare]; |
30 if disable then |
30 if disable then |
31 if user_data then user_data[node] = nil; end |
31 if user_data then user_data[node] = nil; end |
32 if not next(user_data) then data[bare] = nil; end |
32 if not next(user_data) then data[bare] = nil; end |