comparison 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
comparison
equal deleted inserted replaced
24:6c620e9f7d2c 25:d9da5c3e305d
7 pubsub: 'http://jabber.org/protocol/pubsub', 7 pubsub: 'http://jabber.org/protocol/pubsub',
8 pubsub_owner: 'http://jabber.org/protocol/pubsub#owner', 8 pubsub_owner: 'http://jabber.org/protocol/pubsub#owner',
9 avatar_metadata: 'urn:xmpp:avatar:metadata', 9 avatar_metadata: 'urn:xmpp:avatar:metadata',
10 avatar_data: 'urn:xmpp:avatar:data', 10 avatar_data: 'urn:xmpp:avatar:data',
11 nickname: 'http://jabber.org/protocol/nick', 11 nickname: 'http://jabber.org/protocol/nick',
12 vcard4: 'urn:ietf:params:xml:ns:vcard-4.0',
12 mam: 'urn:xmpp:mam:2', 13 mam: 'urn:xmpp:mam:2',
13 forward: 'urn:xmpp:forward:0', 14 forward: 'urn:xmpp:forward:0',
14 }; 15 };
15 16
16 function nsResolver(prefix) { 17 function nsResolver(prefix) {
23 result = XPathResult.FIRST_ORDERED_NODE_TYPE; 24 result = XPathResult.FIRST_ORDERED_NODE_TYPE;
24 const value = elem.getRootNode().evaluate(xpath, elem, nsResolver, result, null); 25 const value = elem.getRootNode().evaluate(xpath, elem, nsResolver, result, null);
25 if (result == XPathResult.FIRST_ORDERED_NODE_TYPE) 26 if (result == XPathResult.FIRST_ORDERED_NODE_TYPE)
26 return value.singleNodeValue; 27 return value.singleNodeValue;
27 return value; 28 return value;
29 }
30
31 function parseXPathText(elem, xpath)
32 {
33 const value = parseXPath(elem, xpath);
34 if (value === null)
35 return null;
36 return value.textContent;
28 } 37 }
29 38
30 function configurePEPField(node, key, value, cb, err_cb) { 39 function configurePEPField(node, key, value, cb, err_cb) {
31 return $iq({type: 'set'}) 40 return $iq({type: 'set'})
32 .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub#owner'}) 41 .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub#owner'})