diff util.js @ 25:d9da5c3e305d

Add support for setting some vCard4 fields.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 23 Dec 2018 16:34:30 +0100
parents 6c620e9f7d2c
children 9ba4f8cc32f1
line wrap: on
line diff
--- a/util.js
+++ b/util.js
@@ -9,6 +9,7 @@ const NS = {
     avatar_metadata: 'urn:xmpp:avatar:metadata',
     avatar_data: 'urn:xmpp:avatar:data',
     nickname: 'http://jabber.org/protocol/nick',
+    vcard4: 'urn:ietf:params:xml:ns:vcard-4.0',
     mam: 'urn:xmpp:mam:2',
     forward: 'urn:xmpp:forward:0',
 };
@@ -27,6 +28,14 @@ function parseXPath(elem, xpath, result)
     return value;
 }
 
+function parseXPathText(elem, xpath)
+{
+    const value = parseXPath(elem, xpath);
+    if (value === null)
+        return null;
+    return value.textContent;
+}
+
 function configurePEPField(node, key, value, cb, err_cb) {
     return $iq({type: 'set'})
         .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub#owner'})