mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 03:24:04 +00:00 
			
		
		
		
	Return more information about groups
This commit is contained in:
		@@ -125,20 +125,23 @@ export class GroupsController {
 | 
			
		||||
 | 
			
		||||
		const group = await GroupsHelper.GetInfo(groupID);
 | 
			
		||||
 | 
			
		||||
		h.send(await this.GroupInfoToAPI(group, h));
 | 
			
		||||
		h.send(await this.GroupInfoToAPI(group, h, true));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Turn a GroupInfo object into a valid API object
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param info Information about the group
 | 
			
		||||
	 * @param h Request handler
 | 
			
		||||
	 * @param advanced Specify whether advanced information should be returned
 | 
			
		||||
	 * in the request or not
 | 
			
		||||
	 * @returns Generated object
 | 
			
		||||
	 */
 | 
			
		||||
	private static async GroupInfoToAPI(info: GroupInfo, h: RequestHandler) : Promise<any> {
 | 
			
		||||
	private static async GroupInfoToAPI(info: GroupInfo, h: RequestHandler, advanced: boolean = false) : Promise<any> {
 | 
			
		||||
		
 | 
			
		||||
		const membership = await GroupsHelper.GetMembershipInfo(info.id, h.getUserId())
 | 
			
		||||
		
 | 
			
		||||
		return {
 | 
			
		||||
		const data = {
 | 
			
		||||
			id: info.id,
 | 
			
		||||
			name: info.name,
 | 
			
		||||
			icon_url: info.logoURL,
 | 
			
		||||
@@ -151,5 +154,15 @@ export class GroupsController {
 | 
			
		||||
			membership: GROUPS_MEMBERSHIP_LEVELS[membership ? membership.level : GroupMembershipLevels.VISITOR],
 | 
			
		||||
			following: membership ? membership.following : false
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(advanced) {
 | 
			
		||||
			data["time_create"] = info.timeCreate;
 | 
			
		||||
			data["description"] = info.hasDescription ? info.description : "null";
 | 
			
		||||
			data["url"] = info.url ? info.hasURL : "null";
 | 
			
		||||
 | 
			
		||||
			//TODO : add likes information
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return data;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user