From 0925b44492af78437c022642f93eb12e0009cb40 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 24 Dec 2019 19:10:45 +0100 Subject: [PATCH] Ready to return advanced info --- src/controllers/GroupsController.ts | 13 +++++++++++++ src/controllers/Routes.ts | 2 ++ src/entities/Group.ts | 8 +++++++- src/helpers/GroupsHelper.ts | 5 ++++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/controllers/GroupsController.ts b/src/controllers/GroupsController.ts index 2341ea9..f057bf1 100644 --- a/src/controllers/GroupsController.ts +++ b/src/controllers/GroupsController.ts @@ -115,6 +115,19 @@ export class GroupsController { h.send(result); } + /** + * Get advanced information about a group + * + * @param h Request handler + */ + public static async GetAdvancedInfo(h: RequestHandler) { + const groupID = await h.postGroupIDWithAccess("id", GroupsAccessLevel.VIEW_ACCESS); + + const group = await GroupsHelper.GetInfo(groupID); + + h.send(await this.GroupInfoToAPI(group, h)); + } + /** * Turn a GroupInfo object into a valid API object * diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index 311cd52..5ccc318 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -92,4 +92,6 @@ export const Routes : Route[] = [ {path: "/groups/get_info", cb: (h) => GroupsController.GetInfoSingle(h)}, {path: "/groups/get_multiple_info", cb: (h) => GroupsController.GetInfoMultiple(h)}, + + {path: "/groups/get_advanced_info", cb: (h) => GroupsController.GetAdvancedInfo(h)}, ] \ No newline at end of file diff --git a/src/entities/Group.ts b/src/entities/Group.ts index 7be02a1..259c3dc 100644 --- a/src/entities/Group.ts +++ b/src/entities/Group.ts @@ -52,10 +52,16 @@ export interface GroupInfoConstructor { registrationLevel: GroupRegistrationLevel, postsCreationLevel: GroupPostsCreationLevel, logo ?: string, - virtualDirectory ?: string + virtualDirectory ?: string, + timeCreate: number, + description ?: string, + url ?: string, } export class GroupInfo implements GroupInfoConstructor { + timeCreate: number; + description?: string; + url?: string; id: number; name: string; membersCount: number; diff --git a/src/helpers/GroupsHelper.ts b/src/helpers/GroupsHelper.ts index 453b1f4..0368dd1 100644 --- a/src/helpers/GroupsHelper.ts +++ b/src/helpers/GroupsHelper.ts @@ -250,7 +250,10 @@ export class GroupsHelper { registrationLevel: row.registration_level, postsCreationLevel: row.posts_level, logo: (row.path_logo != null && row.path_logo && row.path_logo != "null" ? row.path_logo : undefined), - virtualDirectory: (row.virtual_directory != null && row.virtual_directory && row.virtual_directory != "null" ? row.virtual_directory : undefined) + virtualDirectory: (row.virtual_directory != null && row.virtual_directory && row.virtual_directory != "null" ? row.virtual_directory : undefined), + timeCreate: row.time_create, + description: (row.description != null && row.description && row.description != "null" ? row.description : undefined), + url: (row.url != null && row.url && row.url != "null" ? row.url : undefined) }); }