Prosody top-level error handler modified to log properly on non-string error messages.
[prosody.git] / plugins / mod_pep.lua
index 8cc4aedfb6004a5c85417802c8608273b8a2fc8a..bfe2286763117a299ce2e4bb641e922a15f99828 100644 (file)
@@ -25,11 +25,22 @@ local data = {};
 local recipients = {};
 local hash_map = {};
 
-module:add_identity("pubsub", "pep");
+module.save = function()
+       return { data = data, recipients = recipients, hash_map = hash_map };
+end
+module.restore = function(state)
+       data = state.data or {};
+       recipients = state.recipients or {};
+       hash_map = state.hash_map or {};
+end
+
+module:add_identity("pubsub", "pep", "Prosody");
 module:add_feature("http://jabber.org/protocol/pubsub#publish");
 
 local function publish(session, node, item)
+       item.attr.xmlns = nil;
        local disable = #item.tags ~= 1 or #item.tags[1].tags == 0;
+       if #item.tags == 0 then item.name = "retract"; end
        local bare = session.username..'@'..session.host;
        local stanza = st.message({from=bare, type='headline'})
                :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'})
@@ -128,11 +139,12 @@ module:hook("iq/bare/http://jabber.org/protocol/pubsub:pubsub", function(event)
                local payload = stanza.tags[1];
                if payload.name == 'pubsub' then -- <pubsub xmlns='http://jabber.org/protocol/pubsub'>
                        payload = payload.tags[1];
-                       if payload and payload.name == 'publish' and payload.attr.node then -- <publish node='http://jabber.org/protocol/tune'>
+                       if payload and (payload.name == 'publish' or payload.name == 'retract') and payload.attr.node then -- <publish node='http://jabber.org/protocol/tune'>
                                local node = payload.attr.node;
                                payload = payload.tags[1];
-                               if payload then -- <item>
-                                       publish(session, node, payload);
+                               if payload and payload.name == "item" then -- <item>
+                                       session.send(st.reply(stanza));
+                                       publish(session, node, st.clone(payload));
                                        return true;
                                end
                        end