From ff05b0773d91b5449e382db943d99db4dd7bbfbb Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Oct 2024 15:23:45 +0100 Subject: mod_pubsub: Allow passing additional error context Sometimes it is useful to pass additional information along. --- plugins/mod_pubsub/pubsub.lib.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/mod_pubsub') diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index a7379ab3..f2980c18 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -33,11 +33,11 @@ local pubsub_errors = errors.init("pubsub", xmlns_pubsub_errors, { ["invalid-item"] = { "modify", "bad-request", "invalid item" }; ["persistent-items-unsupported"] = { "cancel", "feature-not-implemented", nil, "persistent-items" }; }); -local function pubsub_error_reply(stanza, error) +local function pubsub_error_reply(stanza, error, context) if type(error) == "table" and type(error.pubsub_condition) == "string" then error.extra = { namespace = xmlns_pubsub_errors; condition = error.pubsub_condition } end - local reply = st.error_reply(stanza, pubsub_errors.wrap(error)); + local reply = st.error_reply(stanza, pubsub_errors.wrap(error, context)); return reply; end _M.pubsub_error_reply = pubsub_error_reply; @@ -680,7 +680,7 @@ function handlers.set_publish(origin, stanza, publish, service) if item then item.attr.publisher = service.config.normalize_jid(stanza.attr.from); end - local ok, ret = service:publish(node, stanza.attr.from, id, item, required_config); + local ok, ret, context = service:publish(node, stanza.attr.from, id, item, required_config); local reply; if ok then if type(ok) == "string" then @@ -691,7 +691,7 @@ function handlers.set_publish(origin, stanza, publish, service) :tag("publish", { node = node }) :tag("item", { id = id }); else - reply = pubsub_error_reply(stanza, ret); + reply = pubsub_error_reply(stanza, ret, context); end origin.send(reply); return true; -- cgit v1.2.3