comparison mod_profile/mod_profile.lua @ 1446:843769eb40c3

mod_profile: Don't include photo in vCard4 version (use XEP-0084 instead)
author Kim Alvefur <zash@zash.se>
date Wed, 25 Jun 2014 20:45:01 +0200
parents 253e374824a8
children 019746bba318
comparison
equal deleted inserted replaced
1445:ae1d7665cde9 1446:843769eb40c3
4 local jid_split, jid_bare = import("util.jid", "split", "bare"); 4 local jid_split, jid_bare = import("util.jid", "split", "bare");
5 local is_admin = require"core.usermanager".is_admin; 5 local is_admin = require"core.usermanager".is_admin;
6 local vcard = require"util.vcard"; 6 local vcard = require"util.vcard";
7 local base64 = require"util.encodings".base64; 7 local base64 = require"util.encodings".base64;
8 local sha1 = require"util.hashes".sha1; 8 local sha1 = require"util.hashes".sha1;
9 local t_insert, t_remove = table.insert, table.remove;
9 10
10 local pep_plus; 11 local pep_plus;
11 if module:get_host_type() == "local" and module:get_option_boolean("vcard_to_pep", true) then 12 if module:get_host_type() == "local" and module:get_option_boolean("vcard_to_pep", true) then
12 pep_plus = module:depends"pep_plus"; 13 pep_plus = module:depends"pep_plus";
13 end 14 end
42 return "application/octet-stream"; 43 return "application/octet-stream";
43 end 44 end
44 45
45 local function update_pep(username, data) 46 local function update_pep(username, data)
46 local pep = pep_plus.get_pep_service(username.."@"..module.host); 47 local pep = pep_plus.get_pep_service(username.."@"..module.host);
48 local photo, p = get_item(data, "PHOTO");
47 if vcard.to_vcard4 then 49 if vcard.to_vcard4 then
50 if p then t_remove(data, p); end
48 pep:purge("urn:xmpp:vcard4", true); 51 pep:purge("urn:xmpp:vcard4", true);
49 pep:publish("urn:xmpp:vcard4", true, "current", st.stanza("item", {id="current"}) 52 pep:publish("urn:xmpp:vcard4", true, "current", st.stanza("item", {id="current"})
50 :add_child(vcard.to_vcard4(data))); 53 :add_child(vcard.to_vcard4(data)));
54 if p then t_insert(data, p, photo); end
51 end 55 end
52 56
53 local nickname = get_item(data, "NICKNAME"); 57 local nickname = get_item(data, "NICKNAME");
54 if nickname and nickname[1] then 58 if nickname and nickname[1] then
55 pep:purge("http://jabber.org/protocol/nick", true); 59 pep:purge("http://jabber.org/protocol/nick", true);
56 pep:publish("http://jabber.org/protocol/nick", true, "current", st.stanza("item", {id="current"}) 60 pep:publish("http://jabber.org/protocol/nick", true, "current", st.stanza("item", {id="current"})
57 :tag("nick", { xmlns="http://jabber.org/protocol/nick" }):text(nickname[1])); 61 :tag("nick", { xmlns="http://jabber.org/protocol/nick" }):text(nickname[1]));
58 end 62 end
59 63
60 local photo = get_item(data, "PHOTO");
61 if photo and photo[1] then 64 if photo and photo[1] then
62 local photo_raw = base64.decode(photo[1]); 65 local photo_raw = base64.decode(photo[1]);
63 local photo_hash = sha1(photo_raw, true); 66 local photo_hash = sha1(photo_raw, true);
64 67
65 pep:purge("urn:xmpp:avatar:metadata", true); 68 pep:purge("urn:xmpp:avatar:metadata", true);