Software /
code /
prosody-modules
Comparison
mod_pep_vcard_avatar/mod_pep_vcard_avatar.lua @ 2149:d9e91240a2dd
mod_pep_vcard_avatar: Return early if no vcard is given
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 03 Apr 2016 00:19:11 +0200 |
parent | 1591:21e439ca7208 |
child | 2150:c1ecc3bc88fa |
comparison
equal
deleted
inserted
replaced
2148:c472a454be61 | 2149:d9e91240a2dd |
---|---|
42 }); | 42 }); |
43 end | 43 end |
44 | 44 |
45 -- vCard -> PEP | 45 -- vCard -> PEP |
46 local function update_pep(session, vcard) | 46 local function update_pep(session, vcard) |
47 local nickname = vcard and vcard:get_child_text("NICKNAME"); | 47 if not vcard then return end |
48 local nickname = vcard:get_child_text("NICKNAME"); | |
48 if nickname then | 49 if nickname then |
49 publish(session, "http://jabber.org/protocol/nick", "current", st.stanza("item", {id="current"}) | 50 publish(session, "http://jabber.org/protocol/nick", "current", st.stanza("item", {id="current"}) |
50 :tag("nick", { xmlns="http://jabber.org/protocol/nick" }):text(nickname)); | 51 :tag("nick", { xmlns="http://jabber.org/protocol/nick" }):text(nickname)); |
51 end | 52 end |
52 | 53 |
53 local photo = vcard and vcard:get_child("PHOTO"); | 54 local photo = vcard:get_child("PHOTO"); |
54 if photo then | 55 if photo then |
55 local photo_type = photo:get_child_text("TYPE"); | 56 local photo_type = photo:get_child_text("TYPE"); |
56 local photo_b64 = photo:get_child_text("BINVAL"); | 57 local photo_b64 = photo:get_child_text("BINVAL"); |
57 local photo_raw = photo_b64 and base64.decode(photo_b64); | 58 local photo_raw = photo_b64 and base64.decode(photo_b64); |
58 if photo_raw and photo_type then -- Else invalid data or encoding | 59 if photo_raw and photo_type then -- Else invalid data or encoding |