From 653b066a3a206e248dd445d75e6303b8ffc0e542 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 26 Mar 2020 13:09:15 +0100 Subject: [PATCH] Export the list of conversations --- src/controllers/AccountController.ts | 6 +++++- src/controllers/ConversationsController.ts | 2 +- src/entities/AccountExport.ts | 3 +++ src/helpers/AccountHelper.ts | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/controllers/AccountController.ts b/src/controllers/AccountController.ts index 64f5cdc..c317f13 100644 --- a/src/controllers/AccountController.ts +++ b/src/controllers/AccountController.ts @@ -252,7 +252,11 @@ export class AccountController { movies: data.movies.map(MoviesController.MovieToAPI), // Conversations messages - all_conversation_messages: data.conversationMessages.map(ConversationsController.ConversationMessageToAPI) + all_conversation_messages: data.conversationMessages.map(ConversationsController.ConversationMessageToAPI), + + // Conversations list + conversations_list: data.conversations.map(ConversationsController.ConversationToAPI), + }; diff --git a/src/controllers/ConversationsController.ts b/src/controllers/ConversationsController.ts index a3c73fb..1f1c024 100644 --- a/src/controllers/ConversationsController.ts +++ b/src/controllers/ConversationsController.ts @@ -377,7 +377,7 @@ export class ConversationsController { * * @param c */ - private static ConversationToAPI(c : Conversation) : any { + public static ConversationToAPI(c : Conversation) : any { return { ID: c.id, ID_owner: c.ownerID, diff --git a/src/entities/AccountExport.ts b/src/entities/AccountExport.ts index 8e8269c..bb57af7 100644 --- a/src/entities/AccountExport.ts +++ b/src/entities/AccountExport.ts @@ -11,6 +11,7 @@ import { UserLike } from "./UserLike"; import { SurveyResponse } from "./SurveyResponse"; import { Movie } from "./Movie"; import { ConversationMessage } from "./ConversationMessage"; +import { Conversation } from "./Conversation"; export interface AccountExportBuilder { userID: number; @@ -21,6 +22,7 @@ export interface AccountExportBuilder { surveyResponses: SurveyResponse[]; movies: Movie[]; conversationMessages: ConversationMessage[]; + conversations: Conversation[]; } export class AccountExport implements AccountExportBuilder { @@ -32,6 +34,7 @@ export class AccountExport implements AccountExportBuilder { surveyResponses: SurveyResponse[]; movies: Movie[]; conversationMessages: ConversationMessage[]; + conversations: Conversation[]; public constructor(info: AccountExportBuilder) { for (const key in info) { diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index 7b95aa7..088f239 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -410,6 +410,9 @@ export class AccountHelper { // Conversation messages conversationMessages: await ConversationsHelper.ExportAllMessages(userID), + + // Conversations list + conversations: await ConversationsHelper.GetListUser(userID), })