diff --git a/src/controllers/GroupsController.ts b/src/controllers/GroupsController.ts index 8769a49..c945f03 100644 --- a/src/controllers/GroupsController.ts +++ b/src/controllers/GroupsController.ts @@ -216,6 +216,21 @@ export class GroupsController { h.success("Group settings have been successfully updated!"); } + /** + * Check the availability of a virtual directory for a given group + * + * @param h Request handler + */ + public static async CheckVirtualDirectory(h: RequestHandler) { + const groupID = await h.postGroupIDWithAccess("groupID", GroupsAccessLevel.ADMIN_ACCESS); + const virtualDirectory = h.postVirtualDirectory("directory"); + + if(!await checkVirtualDirectoryAvailability(virtualDirectory, groupID, VirtualDirType.GROUP)) + h.error(401, "The requested virtual directory seems not to be available!"); + + h.success("Requested virtual directory seems to be available!"); + } + /** * Turn a GroupInfo object into a valid API object * diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index 854d78d..91203d9 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -98,4 +98,6 @@ export const Routes : Route[] = [ {path: "/groups/get_settings", cb: (h) => GroupsController.GetSettings(h)}, {path: "/groups/set_settings", cb: (h) => GroupsController.SetSettings(h)}, + + {path: "/groups/checkVirtualDirectory", cb: (h) => GroupsController.CheckVirtualDirectory(h)}, ] \ No newline at end of file