From 6be2cda9fba3debabf91b7840371b24e4f82c244 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 26 Dec 2019 13:56:28 +0100 Subject: [PATCH] Check out whether a virtual directory can be taken by a group or not --- src/controllers/GroupsController.ts | 15 +++++++++++++++ src/controllers/Routes.ts | 2 ++ 2 files changed, 17 insertions(+) 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