0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-24 13:40:27 +01:00

added dav client

This commit is contained in:
Jonathan Treffler 2024-11-16 03:26:41 +01:00
parent 816d189422
commit f062b2dd41

54
src/davClient.js Normal file
View file

@ -0,0 +1,54 @@
const DAV_VERDIGADO_NAMESPACE = "{http://verdigado.com/ns}";
const DAV_PROPERTIES = {
ORGANIZATION_FOLDER_ID_PROPERTYNAME: DAV_VERDIGADO_NAMESPACE + "organization-folder-id",
ORGANIZATION_FOLDER_RESOURCE_ID_PROPERTYNAME: DAV_VERDIGADO_NAMESPACE + "organization-folder-resource-id",
ORGANIZATION_FOLDER_RESOURCE_MANAGER_PERMISSIONS_PROPERTYNAME: DAV_VERDIGADO_NAMESPACE + "organization-folder-resource-user-has-manager-permissions",
};
/**
* @member {OC.Files.Client} client
*/
let client
/**
*
* @param {OC.Files.Client} filesClient files dav client
*/
export function initFilesClient(filesClient) {
client = filesClient
client.addFileInfoParser((response) => {
const data = {};
const props = response.propStat[0].properties;
const organizationFolderId = props[DAV_PROPERTIES.ORGANIZATION_FOLDER_ID_PROPERTYNAME];
if (typeof organizationFolderId !== 'undefined') {
data.organizationFolderId = parseInt(organizationFolderId);
}
const organizationFolderResourceId = props[DAV_PROPERTIES.ORGANIZATION_FOLDER_RESOURCE_ID_PROPERTYNAME];
if (typeof organizationFolderResourceId !== 'undefined') {
data.organizationFolderResourceId = parseInt(organizationFolderResourceId);
}
const userManagerPermissions = props[DAV_PROPERTIES.ORGANIZATION_FOLDER_RESOURCE_MANAGER_PERMISSIONS_PROPERTYNAME];
if (typeof userManagerPermissions !== 'undefined') {
data.userManagerPermissions = userManagerPermissions === "true";
}
return data
});
}
(function(OC) {
Object.assign(OC.Files.Client, DAV_PROPERTIES)
})(window.OC)
export async function getFolderProperties(path) {
return client.getFileInfo(path, {
properties: [DAV_PROPERTIES.ORGANIZATION_FOLDER_ID_PROPERTYNAME, DAV_PROPERTIES.ORGANIZATION_FOLDER_RESOURCE_ID_PROPERTYNAME, DAV_PROPERTIES.ORGANIZATION_FOLDER_RESOURCE_MANAGER_PERMISSIONS_PROPERTYNAME],
}).then((status, fileInfo) => {
return {status, fileInfo};
});
}