Software /
code /
prosody-modules
Diff
mod_vjud/mod_vjud.lua @ 2008:cf3bdcb633f0
mod_vjud: Handle vCard decoding errors by logging them (Thanks Roi)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 14 Jan 2016 18:24:35 +0100 |
parent | 1319:400a7fdd2049 |
child | 2179:a90c7d7e7413 |
line wrap: on
line diff
--- a/mod_vjud/mod_vjud.lua Wed Jan 13 23:04:55 2016 +0000 +++ b/mod_vjud/mod_vjud.lua Thu Jan 14 18:24:35 2016 +0100 @@ -59,12 +59,12 @@ }; local function get_user_vcard(user, host) - local vCard = dm_load(user, host or base_host, "vcard"); - if vCard then - vCard = st.deserialize(vCard); - vCard = vcard.from_xep54(vCard); - return setmetatable(vCard, vCard_mt); - end + local vCard err = dm_load(user, host or base_host, "vcard"); + if not vCard then return nil, err; end + vCard = st.deserialize(vCard); + vCard, err = vcard.from_xep54(vCard); + if not vCard then return nil, err; end + return setmetatable(vCard, vCard_mt); end local at_host = "@"..base_host; @@ -102,8 +102,10 @@ local username, hostname = jid_split(email); if hostname == base_host and username and usermanager.user_exists(username, hostname) then - local vCard = get_user_vcard(username); - if vCard then + local vCard, err = get_user_vcard(username); + if not vCard then + module:log("debug", "Couldn't get vCard for user %s: %s", username, err or "unknown error"); + else reply:add_child(item_template.apply{ jid = username..at_host; first = vCard.N and vCard.N[2] or nil;