File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -638,6 +638,38 @@ export default class DavClient {
638638 . filter ( Boolean )
639639 }
640640
641+ /**
642+ * Returns the principal URLs and permission level of users who have granted
643+ * the given principal proxy access (both read and write).
644+ *
645+ * Inspects the group-membership property for groups ending in
646+ * /calendar-proxy-write or /calendar-proxy-read and returns objects with
647+ * the owner's principal URL and the permission granted.
648+ *
649+ * @param {string } principalUrl Absolute URL of the principal
650+ * @return {Promise<Array<{principalUrl: string, permission: 'write'|'read'}>> }
651+ */
652+ async getDelegatorsWithPermission ( principalUrl ) {
653+ const groups = await this . getGroupMembership ( principalUrl )
654+ const result = [ ]
655+
656+ for ( const groupUrl of groups ) {
657+ if ( groupUrl . includes ( 'calendar-proxy-write' ) ) {
658+ const ownerUrl = groupUrl . replace ( / \/ c a l e n d a r - p r o x y - w r i t e \/ ? $ / , '' )
659+ if ( ownerUrl ) {
660+ result . push ( { principalUrl : ownerUrl , permission : 'write' } )
661+ }
662+ } else if ( groupUrl . includes ( 'calendar-proxy-read' ) ) {
663+ const ownerUrl = groupUrl . replace ( / \/ c a l e n d a r - p r o x y - r e a d \/ ? $ / , '' )
664+ if ( ownerUrl ) {
665+ result . push ( { principalUrl : ownerUrl , permission : 'read' } )
666+ }
667+ }
668+ }
669+
670+ return result
671+ }
672+
641673 /**
642674 * discovers all calendar-homes in this account, all principal collections
643675 * and advertised features
You can’t perform that action at this time.
0 commit comments