Right now if I load a module that adds adhoc commands onto a pubsub component host, it does not work.
This is because the adhoc and pubsub modules both hook host-disco-items-node with the same priority and the pubsub module consumes the event in the case of not-found instead of letting that bubble up to mod_disco.
One possible solution is to set the hook in mod_adhoc to a higher priority than 0 and then change the last line to:
event.origin.send(reply);
return true;
I have confirmed that this works.
The other way could be to have mod_pubsub not do the return true in a not-found error case but instead to return nil without setting event.exists to true, thus getting the same not-found error out of mod_disco in the normal case but allowing other modules to respond to the event in the meantime.
Zash
on
Thanks for the report. Sounds like you already had a patch?
Changes
tags Status-Accepted Difficulty-Easy
Stephen Paul Weber
on
Just to update this post 13.0 I am now using this code:
```
function _M.handle_disco_items_node(event, service)
local stanza, reply, node = event.stanza, event.reply, event.node;
local ok, ret = service:get_items(node, stanza.attr.from);
if not ok then
-- event.reply = pubsub_error_reply(stanza, ret);
return nil;
end
for _, id in ipairs(ret) do
reply:tag("item", { jid = service.config.jid or module.host, name = id }):up();
end
event.exists = true;
end
```
Which does also work. Uncommenting the `event.reply =` line results in an empty commands list so that's not quite it.
Right now if I load a module that adds adhoc commands onto a pubsub component host, it does not work. This is because the adhoc and pubsub modules both hook host-disco-items-node with the same priority and the pubsub module consumes the event in the case of not-found instead of letting that bubble up to mod_disco. One possible solution is to set the hook in mod_adhoc to a higher priority than 0 and then change the last line to: event.origin.send(reply); return true; I have confirmed that this works. The other way could be to have mod_pubsub not do the return true in a not-found error case but instead to return nil without setting event.exists to true, thus getting the same not-found error out of mod_disco in the normal case but allowing other modules to respond to the event in the meantime.
Thanks for the report. Sounds like you already had a patch?
ChangesJust to update this post 13.0 I am now using this code: ``` function _M.handle_disco_items_node(event, service) local stanza, reply, node = event.stanza, event.reply, event.node; local ok, ret = service:get_items(node, stanza.attr.from); if not ok then -- event.reply = pubsub_error_reply(stanza, ret); return nil; end for _, id in ipairs(ret) do reply:tag("item", { jid = service.config.jid or module.host, name = id }):up(); end event.exists = true; end ``` Which does also work. Uncommenting the `event.reply =` line results in an empty commands list so that's not quite it.