Merge s2s branch
[prosody.git] / plugins / mod_pubsub.lua
index 8f078f54fbd075fe06945d190b1731b56523ebf6..22969ab5f067d9fee54364c8ffc933d9fcf6bb99 100644 (file)
@@ -22,7 +22,9 @@ function handle_pubsub_iq(event)
        local origin, stanza = event.origin, event.stanza;
        local pubsub = stanza.tags[1];
        local action = pubsub.tags[1];
-       if not action then return; end
+       if not action then
+               return origin.send(st.error_reply(stanza, "cancel", "bad-request"));
+       end
        local handler = handlers[stanza.attr.type.."_"..action.name];
        if handler then
                handler(origin, stanza, action);
@@ -188,7 +190,13 @@ function handlers.set_publish(origin, stanza, publish)
                return origin.send(pubsub_error_reply(stanza, "nodeid-required"));
        end
        local item = publish:get_child("item");
-       local id = (item and item.attr.id) or uuid_generate();
+       local id = (item and item.attr.id);
+       if not id then
+               id = uuid_generate();
+               if item then
+                       item.attr.id = id;
+               end
+       end
        local ok, ret = service:publish(node, stanza.attr.from, id, item);
        local reply;
        if ok then