diff --git a/src/controllers/AccountController.ts b/src/controllers/AccountController.ts index c04b4e0..6cfa0f3 100644 --- a/src/controllers/AccountController.ts +++ b/src/controllers/AccountController.ts @@ -13,6 +13,8 @@ import { SurveyController } from "./SurveyController"; import { MoviesController } from "./MoviesController"; import { ConversationsController } from "./ConversationsController"; import { FriendsController } from "./FriendsController"; +import { GroupsHelper } from "../helpers/GroupsHelper"; +import { GroupsController } from "./GroupsController"; /** * Account controller @@ -264,6 +266,10 @@ export class AccountController { // Friends list friends_list: data.friendsList.map(f => FriendsController.FriendToAPI(f, false)), + // Groups membership + groups: await Promise.all((await Promise.all(data.groups.map(id => GroupsHelper.GetInfo(id)))) + .map(info => GroupsController.GroupInfoToAPI(info, h, false))), + // Related users info users_info: new Map(), }; diff --git a/src/controllers/GroupsController.ts b/src/controllers/GroupsController.ts index f05a884..657b51c 100644 --- a/src/controllers/GroupsController.ts +++ b/src/controllers/GroupsController.ts @@ -583,7 +583,7 @@ export class GroupsController { * in the request or not * @returns Generated object */ - private static async GroupInfoToAPI(info: GroupInfo, h: RequestHandler, advanced: boolean = false) : Promise { + public static async GroupInfoToAPI(info: GroupInfo, h: RequestHandler, advanced: boolean = false) : Promise { const membership = await GroupsHelper.GetMembershipInfo(info.id, h.optionnalUserID) diff --git a/src/entities/AccountExport.ts b/src/entities/AccountExport.ts index 1ca7f5e..412f067 100644 --- a/src/entities/AccountExport.ts +++ b/src/entities/AccountExport.ts @@ -27,6 +27,7 @@ export interface AccountExportBuilder { conversations: Conversation[]; conversationsMessages: Map; friendsList: Friend[]; + groups: number[]; } export class AccountExport implements AccountExportBuilder { @@ -41,6 +42,7 @@ export class AccountExport implements AccountExportBuilder { conversations: Conversation[]; conversationsMessages: Map; friendsList: Friend[]; + groups: number[]; public constructor(info: AccountExportBuilder) { for (const key in info) { diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index 5f18c14..0920d84 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -14,6 +14,7 @@ import { SurveyHelper } from "./SurveyHelper"; import { MoviesHelper } from "./MoviesHelper"; import { ConversationsHelper } from "./ConversationsHelper"; import { FriendsHelper } from "./FriendsHelper"; +import { GroupsHelper } from "./GroupsHelper"; /** * Account helper @@ -421,7 +422,8 @@ export class AccountHelper { // Friends friendsList: await FriendsHelper.GetList(userID), - // TODO : add groups list + // Groups membership + groups: await GroupsHelper.GetListUser(userID), }) // Process conversation messages