mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 11:34:04 +00:00 
			
		
		
		
	Can invite a user to join a group
This commit is contained in:
		@@ -289,6 +289,25 @@ export class GroupsController {
 | 
			
		||||
		h.send(members.map((m) => this.GroupMemberToAPI(m)));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Invite a user to join the network
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param h Request handler
 | 
			
		||||
	 */
 | 
			
		||||
	public static async InviteUser(h: RequestHandler) {
 | 
			
		||||
		const groupID = await h.postGroupIDWithAccess("group_id", GroupsAccessLevel.MODERATOR_ACCESS);
 | 
			
		||||
		const userID = await h.postUserId("userID");
 | 
			
		||||
 | 
			
		||||
		if(!await GroupsHelper.GetMembershipLevel(groupID, userID))
 | 
			
		||||
			h.error(401, "The user is not a visitor of the group!");
 | 
			
		||||
		
 | 
			
		||||
		await GroupsHelper.SendInvitation(groupID, userID);
 | 
			
		||||
 | 
			
		||||
		// TODO : Create a notification
 | 
			
		||||
 | 
			
		||||
		h.success("The user has been successfully invited to join the group!");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Turn a GroupInfo object into a valid API object
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
@@ -106,4 +106,6 @@ export const Routes : Route[] = [
 | 
			
		||||
	{path: "/groups/delete_logo", cb: (h) => GroupsController.DeleteLogo(h)},
 | 
			
		||||
 | 
			
		||||
	{path: "/groups/get_members", cb: (h) => GroupsController.GetMembers(h)},
 | 
			
		||||
 | 
			
		||||
	{path: "/groups/invite", cb: (h) => GroupsController.InviteUser(h)},
 | 
			
		||||
]
 | 
			
		||||
		Reference in New Issue
	
	Block a user