Mercurial > prosody-modules
comparison mod_vjud/mod_vjud.lua @ 734:81de1e446bfe
mod_vjud: Don't break on undefined properties.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 01 Jul 2012 13:51:26 +0200 |
parents | dd3b30c0dc8a |
children | da8f561d79b4 |
comparison
equal
deleted
inserted
replaced
733:dd3b30c0dc8a | 734:81de1e446bfe |
---|---|
3 | 3 |
4 local usermanager = require "core.usermanager"; | 4 local usermanager = require "core.usermanager"; |
5 local dataforms_new = require "util.dataforms".new; | 5 local dataforms_new = require "util.dataforms".new; |
6 local jid_split = require "util.jid".prepped_split; | 6 local jid_split = require "util.jid".prepped_split; |
7 local vcard = module:require "vcard"; | 7 local vcard = module:require "vcard"; |
8 local rawget, rawset = rawget, rawset; | |
8 | 9 |
9 local st = require "util.stanza"; | 10 local st = require "util.stanza"; |
10 local template = require "util.template"; | 11 local template = require "util.template"; |
11 | 12 |
12 local get_reply = template[[ | 13 local get_reply = template[[ |
46 type = "boolean", | 47 type = "boolean", |
47 }, | 48 }, |
48 }; | 49 }; |
49 local vCard_mt = { | 50 local vCard_mt = { |
50 __index = function(t, k) | 51 __index = function(t, k) |
52 if type(k) ~= "string" then return nil end | |
51 for i=1,#t do | 53 for i=1,#t do |
52 if t[i].name == k then | 54 local t_i = rawget(t, i); |
53 t[k] = t[i]; | 55 if t_i and t_i.name == k then |
54 return t[i] | 56 rawset(t, k, t_i); |
57 return t_i; | |
55 end | 58 end |
56 end | 59 end |
57 end | 60 end |
58 }; | 61 }; |
59 | 62 |
60 local function get_user_vcard(user) | 63 local function get_user_vcard(user) |
61 local vCard = dm_load(user, module.host, "vcard"); | 64 local vCard = dm_load(user, module.host, "vcard"); |
62 if vCard then | 65 if vCard then |
66 module:log("warn", require"util.serialization".serialize(vCard)); | |
63 vCard = st.deserialize(vCard); | 67 vCard = st.deserialize(vCard); |
68 module:log("warn", require"util.serialization".serialize(vCard)); | |
64 vCard = vcard.from_xep54(vCard); | 69 vCard = vcard.from_xep54(vCard); |
70 module:log("warn", require"util.serialization".serialize(vCard)); | |
65 return setmetatable(vCard, vCard_mt); | 71 return setmetatable(vCard, vCard_mt); |
66 end | 72 end |
67 end | 73 end |
68 | 74 |
69 local at_host = "@"..module.host; | 75 local at_host = "@"..module.host; |