# HG changeset patch # User Kim Alvefur # Date 1572628153 -3600 # Node ID 1010a1ff8d2160aa110787b6acea8aabc055492e # Parent c05444119e9ec2bbc2f41a56a9d14336a80ba082 mod_register_ibr: Allow registartion rejection reason as util.error object diff -r c05444119e9e -r 1010a1ff8d21 plugins/mod_register_ibr.lua --- a/plugins/mod_register_ibr.lua Wed Oct 30 17:33:52 2019 +0100 +++ b/plugins/mod_register_ibr.lua Fri Nov 01 18:09:13 2019 +0100 @@ -168,8 +168,15 @@ module:fire_event("user-registering", user); if not user.allowed then log("debug", "Registration disallowed by module: %s", user.reason or "no reason given"); - -- TODO This could use util.error - session.send(st.error_reply(stanza, user.error_type or "modify", user.error_condition or "not-acceptable", user.reason)); + local error_type, error_condition, reason; + local err = user.error; + if err then + error_type, error_condition, reason = err.type, err.condition, err.text; + else + -- COMPAT pre-util.error + error_type, error_condition, reason = user.error_type, user.error_condition, user.reason; + end + session.send(st.error_reply(stanza, error_type or "modify", error_condition or "not-acceptable", reason)); return true; end