1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 16:45:16 +00:00

Can create new groups

This commit is contained in:
2019-12-24 18:47:55 +01:00
parent 679bf0e04e
commit e85bdf8e54
4 changed files with 94 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import { RequestHandler } from "../entities/RequestHandler";
import { GroupsHelper } from "../helpers/GroupsHelper";
import { GroupsAccessLevel, GroupInfo, GroupVisibilityLevel, GroupPostsCreationLevel, GroupRegistrationLevel } from "../entities/Group";
import { GroupMembershipLevels } from "../entities/GroupMember";
import { time } from "../utils/DateUtils";
/**
* Groups API controller
@ -48,6 +49,26 @@ GROUPS_POSTS_LEVELS[GroupPostsCreationLevel.POSTS_LEVEL_ALL_MEMBERS] = "members"
export class GroupsController {
/**
* Create a new group
*
* @param h Request handler
*/
public static async Create(h: RequestHandler) {
const name = h.postString("name", 3);
const groupID = await GroupsHelper.Create({
name: name,
userID: h.getUserId(),
timeCreate: time()
});
h.send({
success: "The group has been successfully created!",
id: groupID
});
}
/**
* Get the list of groups of the user
*

View File

@ -85,6 +85,8 @@ export const Routes : Route[] = [
// Groups controller
{path: "/groups/create", cb: (h) => GroupsController.Create(h)},
{path: "/groups/get_my_list", cb: (h) => GroupsController.GetListUser(h)},
{path: "/groups/get_info", cb: (h) => GroupsController.GetInfoSingle(h)},