aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-09-06 23:33:44 +0200
committerKim Alvefur <zash@zash.se>2018-09-06 23:33:44 +0200
commitd8c32ef0a30dea449b08412eeafac3c6c0f17aa4 (patch)
treedca6b0a1da8e2f4dc4c3b19e7c1c5419d076f22c
parentebfed28595275e68a85f8c70c859e7cf91c57ca4 (diff)
downloadprosody-d8c32ef0a30dea449b08412eeafac3c6c0f17aa4.tar.gz
prosody-d8c32ef0a30dea449b08412eeafac3c6c0f17aa4.zip
mod_vcard_legacy: Factor out error handling into a function
This is a lite version of pubsub_error_reply() in mod_pubsub
-rw-r--r--plugins/mod_vcard_legacy.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/plugins/mod_vcard_legacy.lua b/plugins/mod_vcard_legacy.lua
index 4320d96c..f52306f4 100644
--- a/plugins/mod_vcard_legacy.lua
+++ b/plugins/mod_vcard_legacy.lua
@@ -13,6 +13,16 @@ module:hook("account-disco-info", function (event)
event.reply:tag("feature", { var = "urn:xmpp:pep-vcard-conversion:0" }):up();
end);
+local function handle_error(origin, stanza, err)
+ if err == "forbidden" then
+ origin.send(st.error_reply(stanza, "auth", "forbidden"));
+ elseif err == "internal-server-error" then
+ origin.send(st.error_reply(stanza, "wait", "internal-server-error"));
+ else
+ origin.send(st.error_reply(stanza, "modify", "undefined-condition", err));
+ end
+end
+
-- Simple translations
-- <foo><text>hey</text></foo> -> <FOO>hey</FOO>
local simple_map = {
@@ -240,12 +250,8 @@ module:hook("iq-set/self/vcard-temp:vCard", function (event)
local ok, err = pep_service:publish("urn:xmpp:vcard4", origin.full_jid, "current", vcard4);
if ok then
origin.send(st.reply(stanza));
- elseif err == "forbidden" then
- origin.send(st.error_reply(stanza, "auth", "forbidden"));
- elseif err == "internal-server-error" then
- origin.send(st.error_reply(stanza, "wait", "internal-server-error"));
else
- origin.send(st.error_reply(stanza, "modify", "undefined-condition", err));
+ handle_error(origin, stanza, err);
end
return true;