Software /
code /
prosody
Diff
plugins/mod_pubsub/pubsub.lib.lua @ 13535:88cab98aa28c
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 29 Oct 2024 14:56:02 +0100 |
parent | 13533:c885594f7f9a |
child | 13550:eae0272b87e3 |
line wrap: on
line diff
--- a/plugins/mod_pubsub/pubsub.lib.lua Tue Oct 29 14:10:02 2024 +0100 +++ b/plugins/mod_pubsub/pubsub.lib.lua Tue Oct 29 14:56:02 2024 +0100 @@ -34,10 +34,11 @@ ["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;