Comparison

plugins/mod_vcard_legacy.lua @ 9250:9a8006f9e983

mod_vcard_legacy: Attach vcard-temp avatar hash to outgoing presence
author Kim Alvefur <zash@zash.se>
date Mon, 20 Aug 2018 07:36:03 +0200
parent 9249:506aabdb13bc
child 9251:3f31e10e8256
comparison
equal deleted inserted replaced
9249:506aabdb13bc 9250:9a8006f9e983
51 end 51 end
52 52
53 origin.send(st.reply(stanza):add_child(vcard_temp)); 53 origin.send(st.reply(stanza):add_child(vcard_temp));
54 return true; 54 return true;
55 end); 55 end);
56
57 local function inject_xep153(event)
58 local origin, stanza = event.origin, event.stanza;
59 local username = origin.username;
60 if not username then return end
61 local pep = mod_pep.get_pep_service(username);
62
63 stanza:remove_children("x", "vcard-temp:x:update");
64 local x_update = st.stanza("x", { xmlns = "vcard-temp:x:update" });
65 local ok, avatar_hash = pep:get_last_item("urn:xmpp:avatar:metadata", true);
66 if ok and avatar_hash then
67 x_update:text_tag("photo", avatar_hash);
68 end
69 stanza:add_direct_child(x_update);
70 end
71
72 module:hook("pre-presence/full", inject_xep153, 1);
73 module:hook("pre-presence/bare", inject_xep153, 1);
74 module:hook("pre-presence/host", inject_xep153, 1);