mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-26 07:19:23 +00:00
Can find virtual directory
This commit is contained in:
parent
e96cb38942
commit
90158000c2
@ -6,6 +6,7 @@ import { ConversationsController } from "./ConversationsController";
|
|||||||
import { SearchController } from "./SearchController";
|
import { SearchController } from "./SearchController";
|
||||||
import { GroupsController } from "./GroupsController";
|
import { GroupsController } from "./GroupsController";
|
||||||
import { NotificationsController } from "./NotificationsController";
|
import { NotificationsController } from "./NotificationsController";
|
||||||
|
import { VirtualDirectoryController } from "./VirtualDirectoryController";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controllers routes
|
* Controllers routes
|
||||||
@ -140,4 +141,10 @@ export const Routes : Route[] = [
|
|||||||
{path: "/notifications/count_all_news", cb: (h) => NotificationsController.CountAllNews(h)},
|
{path: "/notifications/count_all_news", cb: (h) => NotificationsController.CountAllNews(h)},
|
||||||
|
|
||||||
{path: "/notifications/get_list_unread", cb: (h) => NotificationsController.GetListUnread(h)},
|
{path: "/notifications/get_list_unread", cb: (h) => NotificationsController.GetListUnread(h)},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Virtual directory controller
|
||||||
|
{path: "/virtualDirectory/find", cb: (h) => VirtualDirectoryController.Find(h)},
|
||||||
|
|
||||||
]
|
]
|
33
src/controllers/VirtualDirectoryController.ts
Normal file
33
src/controllers/VirtualDirectoryController.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
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,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user