mod_admin_adhoc: Mark 'accountjids' field as required in 'end user sessions' command...
[prosody.git] / plugins / mod_pubsub.lua
index 8f078f54fbd075fe06945d190b1731b56523ebf6..926ed4f2e8ba483fec1c7ed930e64776d4c46671 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);
@@ -78,9 +80,6 @@ end
 
 function handlers.get_subscriptions(origin, stanza, subscriptions)
        local node = subscriptions.attr.node;
-       if not node then
-               return origin.send(pubsub_error_reply(stanza, "nodeid-required"));
-       end
        local ok, ret = service:get_subscriptions(node, stanza.attr.from, stanza.attr.from);
        if not ok then
                return origin.send(pubsub_error_reply(stanza, ret));
@@ -188,7 +187,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