Mercurial > prosody-modules
comparison mod_vjud/vcard.lib.lua @ 806:d15a9eaa63ea
mod_vjud/vcard.lib: Handle empty vcards (thanks mva)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 27 Aug 2012 00:06:06 +0200 |
| parents | aeb0999f12fa |
| children | 7dbde05b48a9 |
comparison
equal
deleted
inserted
replaced
| 805:7e474c7f450a | 806:d15a9eaa63ea |
|---|---|
| 96 end | 96 end |
| 97 return t; | 97 return t; |
| 98 end | 98 end |
| 99 | 99 |
| 100 function to_xep54(vCards) | 100 function to_xep54(vCards) |
| 101 if vCards[1].name then | 101 if not vCards[1] or vCards[1].name then |
| 102 return vcard_to_xep54(vCards) | 102 return vcard_to_xep54(vCards) |
| 103 else | 103 else |
| 104 local t = st.stanza("xCard", { xmlns = "vcard-temp" }); | 104 local t = st.stanza("xCard", { xmlns = "vcard-temp" }); |
| 105 for i=1,#vCards do | 105 for i=1,#vCards do |
| 106 t:add_child(vcard_to_xep54(vCards[i])); | 106 t:add_child(vcard_to_xep54(vCards[i])); |
| 211 t_insert(t, "END:VCARD") | 211 t_insert(t, "END:VCARD") |
| 212 return t_concat(t, line_sep); | 212 return t_concat(t, line_sep); |
| 213 end | 213 end |
| 214 | 214 |
| 215 function to_text(vCards) | 215 function to_text(vCards) |
| 216 if vCards[1].name then | 216 if vCards[1] and vCards[1].name then |
| 217 return vcard_to_text(vCards) | 217 return vcard_to_text(vCards) |
| 218 else | 218 else |
| 219 local t = {}; | 219 local t = {}; |
| 220 for i=1,#vCards do | 220 for i=1,#vCards do |
| 221 t[i]=vcard_to_text(vCards[i]); | 221 t[i]=vcard_to_text(vCards[i]); |
