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