mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 11:34:04 +00:00 
			
		
		
		
	Can create new groups
This commit is contained in:
		@@ -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
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
@@ -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)},
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user