MT#15837 mod_sipwise_vcard_cusax: add error when no info is retrive

This removes the lua error when trying to access nil value info.user

http://xmpp.org/rfcs/rfc6120.html#stanzas-error-conditions

Change-Id: Id5709fd4f2b234b6062a6f5433799d35fb90b7f3
changes/88/2988/3
Victor Seva 10 years ago
parent def55257d7
commit ff763a751b

@ -145,10 +145,21 @@ local function handle_vcard(event)
user = session.username;
host = session.host;
end
if not (user and host) then
module:log("error", "bad-request stanza: %s",
tostring(stanza))
session.send(st.error_reply(stanza, "modify", "jid-malformed"));
end
local info = vcard.get_subscriber_info(user, host);
local vCard = generate_vcard(info);
local reply = st.reply(stanza):add_child(st.deserialize(vCard));
session.send(reply);
if info then
local vCard = generate_vcard(info);
local reply = st.reply(stanza):add_child(st.deserialize(vCard));
session.send(reply);
else
module:log("error", "No info retrieve from stanza: %s",
tostring(stanza))
session.send(st.error_reply(stanza, "cancel", "item-not-found"));
end
else
module:log("debug", "reject setting vcard");
session.send(st.error_reply(stanza, "auth", "forbidden"));

Loading…
Cancel
Save