Comparison

plugins/mod_vcard_legacy.lua @ 9273:f2258e9750cf

mod_vcard_legacy: Include avatar data even if metadata can't be loaded Normally both nodes should have the same configuration and matching items, but we can't depend on it without having some code that enforces it, which does not exist at the time of this commit. Including the avatar itself should be prioritised. The image format can be derived from magic bytes.
author Kim Alvefur <zash@zash.se>
date Fri, 07 Sep 2018 01:08:27 +0200
parent 9272:c047be86dd51
child 9284:161f604e14fa
comparison
equal deleted inserted replaced
9272:c047be86dd51 9273:f2258e9750cf
109 end 109 end
110 end 110 end
111 111
112 local meta_ok, avatar_meta = pep_service:get_items("urn:xmpp:avatar:metadata", stanza.attr.from); 112 local meta_ok, avatar_meta = pep_service:get_items("urn:xmpp:avatar:metadata", stanza.attr.from);
113 local data_ok, avatar_data = pep_service:get_items("urn:xmpp:avatar:data", stanza.attr.from); 113 local data_ok, avatar_data = pep_service:get_items("urn:xmpp:avatar:data", stanza.attr.from);
114 if meta_ok and data_ok then 114
115 for _, hash in ipairs(avatar_meta) do 115 if data_ok then
116 local meta = avatar_meta[hash]; 116 for _, hash in ipairs(avatar_data) do
117 local meta = meta_ok and avatar_meta[hash];
117 local data = avatar_data[hash]; 118 local data = avatar_data[hash];
118 local info = meta and meta.tags[1]:get_child("info"); 119 local info = meta and meta.tags[1]:get_child("info");
119 vcard_temp:tag("PHOTO"); 120 vcard_temp:tag("PHOTO");
120 if info and info.attr.type then 121 if info and info.attr.type then
121 vcard_temp:text_tag("TYPE", info.attr.type); 122 vcard_temp:text_tag("TYPE", info.attr.type);