aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2024-10-29 14:56:02 +0100
committerKim Alvefur <zash@zash.se>2024-10-29 14:56:02 +0100
commitc175dc8265beac3ccb64781f0443a38a102bc1ff (patch)
treeb9d7a7fba4983ce11073350596c466b07f9c6a78 /plugins
parent73b512d3a6b988a89852cb7bf027daf8a90a9100 (diff)
downloadprosody-c175dc8265beac3ccb64781f0443a38a102bc1ff.tar.gz
prosody-c175dc8265beac3ccb64781f0443a38a102bc1ff.zip
mod_pubsub: Move precondition error wrangling out of util.pubsub
Removes dependency on util.error from util.pubsub which was only used for this one special case. Line count reduction! Would be even nicer if templating could be done by util.error itself.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_pubsub/pubsub.lib.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua
index f2980c18..5a9be149 100644
--- a/plugins/mod_pubsub/pubsub.lib.lua
+++ b/plugins/mod_pubsub/pubsub.lib.lua
@@ -34,10 +34,11 @@ local pubsub_errors = errors.init("pubsub", xmlns_pubsub_errors, {
["persistent-items-unsupported"] = { "cancel", "feature-not-implemented", nil, "persistent-items" };
});
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 }
+ local err = pubsub_errors.wrap(error, context);
+ if error == "precondition-not-met" and type(context) == "table" and type(context.field) == "string" then
+ err.text = "Field does not match: " .. context.field;
end
- local reply = st.error_reply(stanza, pubsub_errors.wrap(error, context));
+ local reply = st.error_reply(stanza, err);
return reply;
end
_M.pubsub_error_reply = pubsub_error_reply;