diff --git a/src/controllers/GroupsController.ts b/src/controllers/GroupsController.ts index 80ed1ca..d12ee07 100644 --- a/src/controllers/GroupsController.ts +++ b/src/controllers/GroupsController.ts @@ -69,6 +69,31 @@ export class GroupsController { h.send(await this.GroupInfoToAPI(groupInfo, h)); } + /** + * Get information about multiple users + * + * @param h Request handler + */ + public static async GetInfoMultiple(h: RequestHandler) { + const ids = h.postNumbersList("list"); + + const result = {}; + + for (const id of ids) { + + // Check group existence & user authorization + if(!await GroupsHelper.Exists(id) + || await GroupsHelper.GetAccessLevel(id, h.getUserId()) < GroupsAccessLevel.LIMITED_ACCESS) + h.error(404, "Group " + id + " not found"); + + const group = await GroupsHelper.GetInfo(id); + + result[id] = await this.GroupInfoToAPI(group, h); + } + + h.send(result); + } + /** * Turn a GroupInfo object into a valid API object * diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index aaaffc0..27a8894 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -88,4 +88,6 @@ export const Routes : Route[] = [ {path: "/groups/get_my_list", cb: (h) => GroupsController.GetListUser(h)}, {path: "/groups/get_info", cb: (h) => GroupsController.GetInfoSingle(h)}, + + {path: "/groups/get_multiple_info", cb: (h) => GroupsController.GetInfoMultiple(h)}, ] \ No newline at end of file