Changeset

9253:dbe3ae6f9746

mod_vcard_legacy: Include avatar data from XEP-0084 PEP node
author Kim Alvefur <zash@zash.se>
date Mon, 20 Aug 2018 09:18:21 +0200 (2018-08-20)
parents 9252:292d283c7694
children 9254:2ffbcad8ec50
files plugins/mod_vcard_legacy.lua
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_vcard_legacy.lua	Sat Sep 01 23:46:19 2018 +0200
+++ b/plugins/mod_vcard_legacy.lua	Mon Aug 20 09:18:21 2018 +0200
@@ -77,6 +77,20 @@
 		end
 	end
 
+	local meta_ok, avatar_meta = pep_service:get_items("urn:xmpp:avatar:metadata", stanza.attr.from);
+	local data_ok, avatar_data = pep_service:get_items("urn:xmpp:avatar:data", stanza.attr.from);
+	if meta_ok and data_ok then
+		for _, hash in ipairs(avatar_meta) do
+			local meta = avatar_meta[hash];
+			local data = avatar_data[hash];
+			local info = meta.tags[1]:get_child("info");
+			vcard_temp:tag("PHOTO")
+				:text_tag("TYPE", info and info.attr.type)
+				:text_tag("BINVAL", data.tags[1]:get_text())
+				:up();
+		end
+	end
+
 	origin.send(st.reply(stanza):add_child(vcard_temp));
 	return true;
 end);