Mercurial > prosody-modules
comparison mod_profile/mod_profile.lua @ 1422:c3882787ae06
mod_profile: Purge nodes before publishing new items
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 30 May 2014 14:55:54 +0200 |
| parents | 808950ab007b |
| children | 4852fc446d26 |
comparison
equal
deleted
inserted
replaced
| 1421:295c30e44ba8 | 1422:c3882787ae06 |
|---|---|
| 42 end | 42 end |
| 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:publish("urn:xmpp:vcard4", true, "", st.stanza("item"):add_child(vcard.to_vcard4(data))); | 48 pep:publish("urn:xmpp:vcard4", true, "", st.stanza("item"):add_child(vcard.to_vcard4(data))); |
| 48 end | 49 end |
| 49 | 50 |
| 50 local nickname = get_item(data, "NICKNAME"); | 51 local nickname = get_item(data, "NICKNAME"); |
| 51 if nickname and nickname[1] then | 52 if nickname and nickname[1] then |
| 53 pep:purge("http://jabber.org/protocol/nick", true); | |
| 52 pep:publish("http://jabber.org/protocol/nick", true, "", st.stanza("item") | 54 pep:publish("http://jabber.org/protocol/nick", true, "", st.stanza("item") |
| 53 :tag("nick", { xmlns="http://jabber.org/protocol/nick" }):text(nickname[1])); | 55 :tag("nick", { xmlns="http://jabber.org/protocol/nick" }):text(nickname[1])); |
| 54 end | 56 end |
| 55 | 57 |
| 56 local photo = get_item(data, "PHOTO"); | 58 local photo = get_item(data, "PHOTO"); |
| 57 if photo and photo[1] then | 59 if photo and photo[1] then |
| 58 local photo_raw = base64.decode(photo[1]); | 60 local photo_raw = base64.decode(photo[1]); |
| 59 local photo_hash = sha1(photo_raw, true); | 61 local photo_hash = sha1(photo_raw, true); |
| 60 | 62 |
| 63 pep:purge("urn:xmpp:avatar:metadata", true); | |
| 64 pep:purge("urn:xmpp:avatar:data", true); | |
| 61 pep:publish("urn:xmpp:avatar:metadata", true, "", st.stanza("item") | 65 pep:publish("urn:xmpp:avatar:metadata", true, "", st.stanza("item") |
| 62 :tag("metadata", { | 66 :tag("metadata", { |
| 63 xmlns="urn:xmpp:avatar:metadata", | 67 xmlns="urn:xmpp:avatar:metadata", |
| 64 bytes = tostring(#photo_raw), | 68 bytes = tostring(#photo_raw), |
| 65 id = photo_hash, | 69 id = photo_hash, |
