Mercurial > prosody-hg
comparison plugins/mod_vcard_legacy.lua @ 10563:e8db377a2983
Merge 0.11->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 24 Dec 2019 00:39:45 +0100 |
| parents | 3e50f86e5a2e |
| children | 1b657605ea29 |
comparison
equal
deleted
inserted
replaced
| 10562:670afc079f68 | 10563:e8db377a2983 |
|---|---|
| 36 } | 36 } |
| 37 | 37 |
| 38 module:hook("iq-get/bare/vcard-temp:vCard", function (event) | 38 module:hook("iq-get/bare/vcard-temp:vCard", function (event) |
| 39 local origin, stanza = event.origin, event.stanza; | 39 local origin, stanza = event.origin, event.stanza; |
| 40 local pep_service = mod_pep.get_pep_service(jid_split(stanza.attr.to) or origin.username); | 40 local pep_service = mod_pep.get_pep_service(jid_split(stanza.attr.to) or origin.username); |
| 41 local ok, id, vcard4_item = pep_service:get_last_item("urn:xmpp:vcard4", stanza.attr.from); | 41 local ok, _, vcard4_item = pep_service:get_last_item("urn:xmpp:vcard4", stanza.attr.from); |
| 42 | 42 |
| 43 local vcard_temp = st.stanza("vCard", { xmlns = "vcard-temp" }); | 43 local vcard_temp = st.stanza("vCard", { xmlns = "vcard-temp" }); |
| 44 if ok and vcard4_item then | 44 if ok and vcard4_item then |
| 45 local vcard4 = vcard4_item.tags[1]; | 45 local vcard4 = vcard4_item.tags[1]; |
| 46 | 46 |
| 103 vcard_temp:tag("HOME"):up(); | 103 vcard_temp:tag("HOME"):up(); |
| 104 elseif tag:find"parameters/type/text#" == "work" then | 104 elseif tag:find"parameters/type/text#" == "work" then |
| 105 vcard_temp:tag("WORK"):up(); | 105 vcard_temp:tag("WORK"):up(); |
| 106 end | 106 end |
| 107 vcard_temp:up(); | 107 vcard_temp:up(); |
| 108 elseif tag.name == "impp" then | |
| 109 local uri = tag:get_child_text("uri"); | |
| 110 if uri and uri:sub(1, 5) == "xmpp:" then | |
| 111 vcard_temp:text_tag("JABBERID", uri:sub(6)) | |
| 112 end | |
| 113 elseif tag.name == "org" then | |
| 114 vcard_temp:tag("ORG") | |
| 115 :text_tag("ORGNAME", tag:get_child_text("text")) | |
| 116 :up(); | |
| 117 end | |
| 118 end | |
| 119 else | |
| 120 local ok, _, nick_item = pep_service:get_last_item("http://jabber.org/protocol/nick", stanza.attr.from); | |
| 121 if ok and nick_item then | |
| 122 local nickname = nick_item:get_child_text("nick", "http://jabber.org/protocol/nick"); | |
| 123 if nickname then | |
| 124 vcard_temp:text_tag("NICKNAME", nickname); | |
| 108 end | 125 end |
| 109 end | 126 end |
| 110 end | 127 end |
| 111 | 128 |
| 112 local meta_ok, avatar_meta = pep_service:get_items("urn:xmpp:avatar:metadata", stanza.attr.from); | 129 local meta_ok, avatar_meta = pep_service:get_items("urn:xmpp:avatar:metadata", stanza.attr.from); |
| 214 vcard4:text_tag("text", "home"); | 231 vcard4:text_tag("text", "home"); |
| 215 elseif tag:get_child("WORK") then | 232 elseif tag:get_child("WORK") then |
| 216 vcard4:text_tag("text", "work"); | 233 vcard4:text_tag("text", "work"); |
| 217 end | 234 end |
| 218 vcard4:up():up():up(); | 235 vcard4:up():up():up(); |
| 236 elseif tag.name == "JABBERID" then | |
| 237 vcard4:tag("impp") | |
| 238 :text_tag("uri", "xmpp:" .. tag:get_text()) | |
| 239 :up(); | |
| 219 elseif tag.name == "PHOTO" then | 240 elseif tag.name == "PHOTO" then |
| 220 local avatar_type = tag:get_child_text("TYPE"); | 241 local avatar_type = tag:get_child_text("TYPE"); |
| 221 local avatar_payload = tag:get_child_text("BINVAL"); | 242 local avatar_payload = tag:get_child_text("BINVAL"); |
| 222 -- Can EXTVAL be translated? No way to know the sha1 of the data? | 243 -- Can EXTVAL be translated? No way to know the sha1 of the data? |
| 223 | 244 |
