From b45e5c4d0aa76a7a40789425a48250de0e53970f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 21 Mar 2020 18:09:47 +0100 Subject: [PATCH] Can check the availability of a virtual directory for a user --- src/controllers/Routes.ts | 2 ++ src/controllers/SettingsController.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index c2dea1e..ad6bb70 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -85,6 +85,8 @@ export const Routes : Route[] = [ {path: "/settings/set_general", cb: (h) => SettingsController.SetGeneral(h)}, + {path: "/settings/check_user_directory_availability", cb: (h) => SettingsController.CheckDirectoryAvailability(h)}, + // Friends controller {path: "/friends/getList", cb: (h) => FriendsController.GetList(h)}, diff --git a/src/controllers/SettingsController.ts b/src/controllers/SettingsController.ts index af1dab0..4d986eb 100644 --- a/src/controllers/SettingsController.ts +++ b/src/controllers/SettingsController.ts @@ -88,4 +88,19 @@ export class SettingsController { } + + /** + * Check the availablity of a virtual directory for a user + * + * @param h Request handler + */ + public static async CheckDirectoryAvailability(h: RequestHandler) { + const directory = h.postVirtualDirectory("directory"); + + if(!await checkVirtualDirectoryAvailability(directory, h.getUserId(), VirtualDirType.USER)) + h.error(401, "The specified directory is unavailable!"); + + h.success("The directory is available!"); + } + } \ No newline at end of file