import { RequestHandler } from "../entities/RequestHandler"; import { UserHelper } from "../helpers/UserHelper"; import { GroupsHelper } from "../helpers/GroupsHelper"; /** * Virtual directory controller * * @author Pierre HUBERT */ export class VirtualDirectoryController { /** * Find a group / user using a given virtual directory * * @param h Request handler */ public static async Find(h: RequestHandler) { const virtualDirectory = h.postVirtualDirectory("directory"); const userID = await UserHelper.FindByFolder(virtualDirectory); const groupID = await GroupsHelper.FindByVirtualDirectory(virtualDirectory); if(userID < 1 && groupID < 1) h.error(404, "Specified user / group virtual directory not found !") h.send({ kind: userID >= 1 ? "user" : "group", id: userID >= 1 ? userID : groupID, }) } }