mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-11-04 03:24:04 +00:00 
			
		
		
		
	Add membership information when getting group information
This commit is contained in:
		@@ -66,7 +66,7 @@ export class GroupsController {
 | 
			
		||||
		const groupID = await h.postGroupIDWithAccess("id", GroupsAccessLevel.LIMITED_ACCESS);
 | 
			
		||||
		const groupInfo = await GroupsHelper.GetInfo(groupID);
 | 
			
		||||
		
 | 
			
		||||
		h.send(this.GroupInfoToAPI(groupInfo));
 | 
			
		||||
		h.send(await this.GroupInfoToAPI(groupInfo, h));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -75,7 +75,10 @@ export class GroupsController {
 | 
			
		||||
	 * @param info Information about the group
 | 
			
		||||
	 * @returns Generated object
 | 
			
		||||
	 */
 | 
			
		||||
	private static GroupInfoToAPI(info: GroupInfo) : any {
 | 
			
		||||
	private static async GroupInfoToAPI(info: GroupInfo, h: RequestHandler) : Promise<any> {
 | 
			
		||||
		
 | 
			
		||||
		const membership = await GroupsHelper.GetMembershipInfo(info.id, h.getUserId())
 | 
			
		||||
		
 | 
			
		||||
		return {
 | 
			
		||||
			id: info.id,
 | 
			
		||||
			name: info.name,
 | 
			
		||||
@@ -84,7 +87,10 @@ export class GroupsController {
 | 
			
		||||
			visibility: GROUPS_VISIBILITY_LEVELS[info.visiblity],
 | 
			
		||||
			registration_level: GROUPS_REGISTRATION_LEVELS[info.registrationLevel],
 | 
			
		||||
			posts_level: GROUPS_POSTS_LEVELS[info.postsCreationLevel],
 | 
			
		||||
			virtual_directory: info.virtualDirectory,
 | 
			
		||||
			virtual_directory: info.virtualDirectory ? info.virtualDirectory : "null",
 | 
			
		||||
 | 
			
		||||
			membership: GROUPS_MEMBERSHIP_LEVELS[membership ? membership.level : GroupMembershipLevels.VISITOR],
 | 
			
		||||
			following: membership ? membership.following : false
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user