-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Richard Steinmetz <[email protected]>
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* This library is part of the Nextcloud project | ||
* | ||
* @author Georg Ehrke | ||
* @author Richard Steinmetz <[email protected]> | ||
* @copyright 2019 Georg Ehrke <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
|
@@ -445,10 +446,40 @@ export default class DavClient { | |
return this._request.propFind(principalUrl, Principal.getPropFindList()).then(({ body }) => { | ||
return new Principal(null, this._request, principalUrl, body) | ||
}).catch((err) => { | ||
// TODO: improve error handling | ||
console.debug(err) | ||
}) | ||
} | ||
|
||
/** | ||
* finds all principals in a collection at a given principalCollectionUrl | ||
* | ||
* @param {string} principalCollectionUrl | ||
* @param {import('./models/principal.js').PrincipalPropfindOptions} options Passed to Principal.getPropFindList() | ||
* @return {Promise<Principal[]>} | ||
*/ | ||
async findPrincipalsInCollection(principalCollectionUrl, options = {}) { | ||
try { | ||
const { body } = await this._request.propFind( | ||
principalCollectionUrl, | ||
Principal.getPropFindList(options), | ||
1, | ||
) | ||
const principals = Object.entries(body) | ||
.filter(([principalUrl]) => !principalCollectionUrl.endsWith(principalUrl)) | ||
.map(([principalUrl, principal]) => new Principal( | ||
null, | ||
this._request, | ||
principalUrl, | ||
principal, | ||
)) | ||
return principals | ||
} catch (err) { | ||
// TODO: improve error handling | ||
console.debug(err) | ||
} | ||
} | ||
|
||
/** | ||
* discovers the accounts principal uri solely based on rootURL | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters