diff --git a/src/controllers/GroupsController.ts b/src/controllers/GroupsController.ts index f057bf1..06b1736 100644 --- a/src/controllers/GroupsController.ts +++ b/src/controllers/GroupsController.ts @@ -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 { + private static async GroupInfoToAPI(info: GroupInfo, h: RequestHandler, advanced: boolean = false) : Promise { 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; } } \ No newline at end of file diff --git a/src/entities/Group.ts b/src/entities/Group.ts index 259c3dc..079aca6 100644 --- a/src/entities/Group.ts +++ b/src/entities/Group.ts @@ -95,4 +95,12 @@ export class GroupInfo implements GroupInfoConstructor { get logoURL() : string { return pathUserData(this.logoPath, false); } + + get hasDescription() : boolean { + return this.description && true; + } + + get hasURL() : boolean { + return this.url && true; + } } \ No newline at end of file