comparison mod_profile/mod_profile.lua @ 1424:9892a537e7fc

mod_profile: Add id to item tag too.
author Kim Alvefur <zash@zash.se>
date Fri, 30 May 2014 15:05:48 +0200
parents 4852fc446d26
children 07c9306c2c1f
comparison
equal deleted inserted replaced
1423:4852fc446d26 1424:9892a537e7fc
43 43
44 local function update_pep(username, data) 44 local function update_pep(username, data)
45 local pep = pep_plus.get_pep_service(username.."@"..module.host); 45 local pep = pep_plus.get_pep_service(username.."@"..module.host);
46 if vcard.to_vcard4 then 46 if vcard.to_vcard4 then
47 pep:purge("urn:xmpp:vcard4", true); 47 pep:purge("urn:xmpp:vcard4", true);
48 pep:publish("urn:xmpp:vcard4", true, "current", st.stanza("item"):add_child(vcard.to_vcard4(data))); 48 pep:publish("urn:xmpp:vcard4", true, "current", st.stanza("item", {id="current"})
49 :add_child(vcard.to_vcard4(data)));
49 end 50 end
50 51
51 local nickname = get_item(data, "NICKNAME"); 52 local nickname = get_item(data, "NICKNAME");
52 if nickname and nickname[1] then 53 if nickname and nickname[1] then
53 pep:purge("http://jabber.org/protocol/nick", true); 54 pep:purge("http://jabber.org/protocol/nick", true);
54 pep:publish("http://jabber.org/protocol/nick", true, "current", st.stanza("item") 55 pep:publish("http://jabber.org/protocol/nick", true, "current", st.stanza("item", {id="current"})
55 :tag("nick", { xmlns="http://jabber.org/protocol/nick" }):text(nickname[1])); 56 :tag("nick", { xmlns="http://jabber.org/protocol/nick" }):text(nickname[1]));
56 end 57 end
57 58
58 local photo = get_item(data, "PHOTO"); 59 local photo = get_item(data, "PHOTO");
59 if photo and photo[1] then 60 if photo and photo[1] then
60 local photo_raw = base64.decode(photo[1]); 61 local photo_raw = base64.decode(photo[1]);
61 local photo_hash = sha1(photo_raw, true); 62 local photo_hash = sha1(photo_raw, true);
62 63
63 pep:purge("urn:xmpp:avatar:metadata", true); 64 pep:purge("urn:xmpp:avatar:metadata", true);
64 pep:purge("urn:xmpp:avatar:data", true); 65 pep:purge("urn:xmpp:avatar:data", true);
65 pep:publish("urn:xmpp:avatar:metadata", true, "current", st.stanza("item") 66 pep:publish("urn:xmpp:avatar:metadata", true, "current", st.stanza("item", {id="current"})
66 :tag("metadata", { 67 :tag("metadata", {
67 xmlns="urn:xmpp:avatar:metadata", 68 xmlns="urn:xmpp:avatar:metadata",
68 bytes = tostring(#photo_raw), 69 bytes = tostring(#photo_raw),
69 id = photo_hash, 70 id = photo_hash,
70 type = identify(photo_raw), 71 type = identify(photo_raw),
71 })); 72 }));
72 pep:publish("urn:xmpp:avatar:data", true, photo_hash, st.stanza("item") 73 pep:publish("urn:xmpp:avatar:data", true, photo_hash, st.stanza("item", {id="current"})
73 :tag("data", { xmlns="urn:xmpp:avatar:data" }):text(photo[1])); 74 :tag("data", { xmlns="urn:xmpp:avatar:data" }):text(photo[1]));
74 end 75 end
75 end 76 end
76 77
77 -- The "temporary" vCard XEP-0054 part 78 -- The "temporary" vCard XEP-0054 part