Software /
code /
prosody
Comparison
plugins/mod_vcard_legacy.lua @ 9257:05bd21c122ae
mod_vcard_legacy: Handle incomplete avatar info
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 01 Sep 2018 23:42:33 +0200 |
parent | 9256:12d3d96e3918 |
child | 9258:0cc535668fce |
comparison
equal
deleted
inserted
replaced
9256:12d3d96e3918 | 9257:05bd21c122ae |
---|---|
105 local data_ok, avatar_data = pep_service:get_items("urn:xmpp:avatar:data", stanza.attr.from); | 105 local data_ok, avatar_data = pep_service:get_items("urn:xmpp:avatar:data", stanza.attr.from); |
106 if meta_ok and data_ok then | 106 if meta_ok and data_ok then |
107 for _, hash in ipairs(avatar_meta) do | 107 for _, hash in ipairs(avatar_meta) do |
108 local meta = avatar_meta[hash]; | 108 local meta = avatar_meta[hash]; |
109 local data = avatar_data[hash]; | 109 local data = avatar_data[hash]; |
110 local info = meta.tags[1]:get_child("info"); | 110 local info = meta and meta.tags[1]:get_child("info"); |
111 vcard_temp:tag("PHOTO") | 111 vcard_temp:tag("PHOTO"); |
112 :text_tag("TYPE", info and info.attr.type) | 112 if info and info.attr.type then |
113 :text_tag("BINVAL", data.tags[1]:get_text()) | 113 vcard_temp:text_tag("TYPE", info.attr.type); |
114 :up(); | 114 end |
115 if data then | |
116 vcard_temp:text_tag("BINVAL", data.tags[1]:get_text()); | |
117 end | |
118 vcard_temp:up(); | |
115 end | 119 end |
116 end | 120 end |
117 | 121 |
118 origin.send(st.reply(stanza):add_child(vcard_temp)); | 122 origin.send(st.reply(stanza):add_child(vcard_temp)); |
119 return true; | 123 return true; |