1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-26 07:19:23 +00:00

Can get information about multiple groups

This commit is contained in:
Pierre HUBERT 2019-12-24 18:32:44 +01:00
parent 10fb0b8904
commit 679bf0e04e
2 changed files with 27 additions and 0 deletions

View File

@ -69,6 +69,31 @@ export class GroupsController {
h.send(await this.GroupInfoToAPI(groupInfo, h)); 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 * Turn a GroupInfo object into a valid API object
* *

View File

@ -88,4 +88,6 @@ export const Routes : Route[] = [
{path: "/groups/get_my_list", cb: (h) => GroupsController.GetListUser(h)}, {path: "/groups/get_my_list", cb: (h) => GroupsController.GetListUser(h)},
{path: "/groups/get_info", cb: (h) => GroupsController.GetInfoSingle(h)}, {path: "/groups/get_info", cb: (h) => GroupsController.GetInfoSingle(h)},
{path: "/groups/get_multiple_info", cb: (h) => GroupsController.GetInfoMultiple(h)},
] ]