mirror of https://github.com/nextcloud/contacts
dav.js: adding propfind properties for groups, invites and owner
This commit is contained in:
parent
8121297a96
commit
9682b58837
|
@ -1601,7 +1601,9 @@ var listAddressBooks = _co2['default'].wrap(regeneratorRuntime.mark(function cal
|
|||
case 0:
|
||||
debug('Fetch address books from home url ' + account.homeUrl);
|
||||
req = request.propfind({
|
||||
props: [{ name: 'displayname', namespace: ns.DAV }, { name: 'getctag', namespace: ns.CALENDAR_SERVER }, { name: 'resourcetype', namespace: ns.DAV }, { name: 'sync-token', namespace: ns.DAV }],
|
||||
props: [{ name: 'displayname', namespace: ns.DAV }, { name: 'owner', namespace: ns.DAV }, { name: 'getctag', namespace: ns.CALENDAR_SERVER }, { name: 'resourcetype', namespace: ns.DAV }, { name: 'sync-token', namespace: ns.DAV },
|
||||
//{ name: 'groups', namespace: ns.OC },
|
||||
{ name: 'invite', namespace: ns.OC }],
|
||||
depth: 1
|
||||
});
|
||||
context$1$0.next = 4;
|
||||
|
@ -2259,6 +2261,8 @@ var CARDDAV = 'urn:ietf:params:xml:ns:carddav';
|
|||
exports.CARDDAV = CARDDAV;
|
||||
var DAV = 'DAV:';
|
||||
exports.DAV = DAV;
|
||||
var OC = 'http://owncloud.org/ns';
|
||||
exports.OC = OC;
|
||||
},{}],11:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
|
@ -2318,7 +2322,9 @@ var traverse = {
|
|||
resourcetype: false,
|
||||
supportedCalendarComponentSet: false,
|
||||
supportedReportSet: false,
|
||||
currentUserPrincipal: false
|
||||
currentUserPrincipal: false,
|
||||
groups: false,
|
||||
invite: false
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -2328,6 +2334,27 @@ var traverse = {
|
|||
});
|
||||
},
|
||||
|
||||
groups: function groups(node) {
|
||||
return complex(node, { group: true }, 'group');
|
||||
},
|
||||
group: function group(node) {
|
||||
return childNodes(node).map(function (childNode) {
|
||||
return childNode.nodeValue;
|
||||
});
|
||||
},
|
||||
invite: function invite(node) {
|
||||
return complex(node, { user: true }, 'user');
|
||||
},
|
||||
user: function user(node) {
|
||||
return complex(node, { href: false, access: false });
|
||||
},
|
||||
access: function access(node) {
|
||||
return complex(node, {});
|
||||
},
|
||||
//access: node => {
|
||||
// return childNodes(node).map(childNode => childNode.localName);
|
||||
//},
|
||||
|
||||
// [x, y, z]
|
||||
supportedCalendarComponentSet: function supportedCalendarComponentSet(node) {
|
||||
return complex(node, { comp: true }, 'comp');
|
||||
|
@ -2943,6 +2970,8 @@ function xmlnsPrefix(namespace) {
|
|||
return 'c';
|
||||
case ns.CARDDAV:
|
||||
return 'card';
|
||||
case ns.OC:
|
||||
return 'oc';
|
||||
default:
|
||||
throw new Error('Unrecognized xmlns ' + namespace);
|
||||
}
|
||||
|
@ -2963,7 +2992,7 @@ var _prop = require('./prop');
|
|||
var _prop2 = _interopRequireDefault(_prop);
|
||||
|
||||
function propfind(object) {
|
||||
return '<d:propfind xmlns:c="urn:ietf:params:xml:ns:caldav"\n xmlns:card="urn:ietf:params:xml:ns:carddav"\n xmlns:cs="http://calendarserver.org/ns/"\n xmlns:d="DAV:">\n <d:prop>\n ' + object.props.map(_prop2['default']) + '\n </d:prop>\n </d:propfind>';
|
||||
return '<d:propfind xmlns:c="urn:ietf:params:xml:ns:caldav"\n xmlns:card="urn:ietf:params:xml:ns:carddav"\n xmlns:cs="http://calendarserver.org/ns/"\n xmlns:oc="http://owncloud.org/ns"\n xmlns:d="DAV:">\n <d:prop>\n ' + object.props.map(_prop2['default']) + '\n </d:prop>\n </d:propfind>';
|
||||
}
|
||||
|
||||
module.exports = exports['default'];
|
||||
|
|
|
@ -17,9 +17,12 @@ export let listAddressBooks = co.wrap(function *(account, options) {
|
|||
var req = request.propfind({
|
||||
props: [
|
||||
{ name: 'displayname', namespace: ns.DAV },
|
||||
{ name: 'owner', namespace: ns.DAV },
|
||||
{ name: 'getctag', namespace: ns.CALENDAR_SERVER },
|
||||
{ name: 'resourcetype', namespace: ns.DAV },
|
||||
{ name: 'sync-token', namespace: ns.DAV }
|
||||
{ name: 'sync-token', namespace: ns.DAV },
|
||||
//{ name: 'groups', namespace: ns.OC },
|
||||
{ name: 'invite', namespace: ns.OC }
|
||||
],
|
||||
depth: 1
|
||||
});
|
||||
|
|
|
@ -2,3 +2,4 @@ export const CALENDAR_SERVER = 'http://calendarserver.org/ns/';
|
|||
export const CALDAV = 'urn:ietf:params:xml:ns:caldav';
|
||||
export const CARDDAV = 'urn:ietf:params:xml:ns:carddav';
|
||||
export const DAV = 'DAV:';
|
||||
export const OC = 'http://owncloud.org/ns';
|
||||
|
|
|
@ -39,7 +39,9 @@ let traverse = {
|
|||
resourcetype: false,
|
||||
supportedCalendarComponentSet: false,
|
||||
supportedReportSet: false,
|
||||
currentUserPrincipal: false
|
||||
currentUserPrincipal: false,
|
||||
groups: false,
|
||||
invite: false
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -47,6 +49,17 @@ let traverse = {
|
|||
return childNodes(node).map(childNode => childNode.localName);
|
||||
},
|
||||
|
||||
groups: node => complex(node, { group: true }, 'group'),
|
||||
group: node => {
|
||||
return childNodes(node).map(childNode => childNode.nodeValue);
|
||||
},
|
||||
invite: node => complex(node, { user: true }, 'user'),
|
||||
user: node => complex(node, { href: false, access:false }),
|
||||
access: node => complex(node, {}),
|
||||
//access: node => {
|
||||
// return childNodes(node).map(childNode => childNode.localName);
|
||||
//},
|
||||
|
||||
// [x, y, z]
|
||||
supportedCalendarComponentSet: node => complex(node, { comp: true }, 'comp'),
|
||||
|
||||
|
|
|
@ -59,6 +59,8 @@ function xmlnsPrefix(namespace) {
|
|||
return 'c';
|
||||
case ns.CARDDAV:
|
||||
return 'card';
|
||||
case ns.OC:
|
||||
return 'oc';
|
||||
default:
|
||||
throw new Error('Unrecognized xmlns ' + namespace);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ export default function propfind(object) {
|
|||
return `<d:propfind xmlns:c="urn:ietf:params:xml:ns:caldav"
|
||||
xmlns:card="urn:ietf:params:xml:ns:carddav"
|
||||
xmlns:cs="http://calendarserver.org/ns/"
|
||||
xmlns:oc="http://owncloud.org/ns"
|
||||
xmlns:d="DAV:">
|
||||
<d:prop>
|
||||
${object.props.map(prop)}
|
||||
|
|
|
@ -11,6 +11,7 @@ export default docs;
|
|||
'current_user_principal',
|
||||
'calendar_query',
|
||||
'propfind',
|
||||
'propfind_oc',
|
||||
'sync_collection'
|
||||
].forEach(function(responseType) {
|
||||
var camelCase = camelize(responseType);
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<d:multistatus xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns/">
|
||||
<d:response>
|
||||
<d:href>/calendars/admin/</d:href>
|
||||
<d:propstat>
|
||||
<d:prop>
|
||||
<d:owner>
|
||||
<d:href>/remote.php/dav/principals/users/admin/</d:href>
|
||||
</d:owner>
|
||||
<oc:groups>
|
||||
<oc:group>Friends</oc:group>
|
||||
<oc:group>Co-Workers</oc:group>
|
||||
</oc:groups>
|
||||
<oc:invite>
|
||||
<oc:user>
|
||||
<d:href>principal:principals/users/user01</d:href>
|
||||
<oc:common-name>user01</oc:common-name>
|
||||
<oc:invite-accepted/>
|
||||
<oc:access>
|
||||
|
||||
<oc:read/>
|
||||
</oc:access>
|
||||
</oc:user>
|
||||
<oc:user>
|
||||
<d:href>principal:principals/users/user02</d:href>
|
||||
<oc:common-name>user02</oc:common-name>
|
||||
<oc:invite-accepted/>
|
||||
<oc:access>
|
||||
<oc:read/>
|
||||
</oc:access>
|
||||
</oc:user>
|
||||
</oc:invite>
|
||||
</d:prop>
|
||||
<d:status>HTTP/1.1 200 OK</d:status>
|
||||
</d:propstat>
|
||||
</d:response>
|
||||
</d:multistatus>
|
|
@ -63,4 +63,31 @@ suite('parser.multistatus', function() {
|
|||
syncToken: 'http://sabre.io/ns/sync/3'
|
||||
});
|
||||
});
|
||||
|
||||
test('propfind (oc-groups and oc-invites)', function() {
|
||||
let propfind = data.propfindOc;
|
||||
assert.deepEqual(multistatus(propfind), {
|
||||
response: [{
|
||||
href: '/calendars/admin/',
|
||||
propstat: [{
|
||||
prop: {
|
||||
owner: '/remote.php/dav/principals/users/admin/',
|
||||
invite: [{
|
||||
href: 'principal:principals/users/user01',
|
||||
access: {'read':''},
|
||||
commonName: 'user01',
|
||||
inviteAccepted: ''
|
||||
}, {
|
||||
href: 'principal:principals/users/user02',
|
||||
access: {'read':''},
|
||||
commonName: 'user02',
|
||||
inviteAccepted: ''
|
||||
}],
|
||||
groups: ['Friends', 'Co-Workers']
|
||||
},
|
||||
status: 'HTTP/1.1 200 OK'
|
||||
}]
|
||||
}],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue