mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29:22 +00:00
Can get information about multiple groups
This commit is contained in:
parent
10fb0b8904
commit
679bf0e04e
@ -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
|
||||
*
|
||||
|
@ -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)},
|
||||
]
|
Loading…
Reference in New Issue
Block a user