1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 00:25:17 +00:00

Export all user comments

This commit is contained in:
2020-03-25 18:55:25 +01:00
parent 336923bee7
commit 09b2eed63d
4 changed files with 28 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import { NewAccount } from "../entities/NewAccount";
import { GeneralSettings, UserPageStatus, LangSettings, SecuritySettings } from "../entities/User";
import { AccountExport } from "../entities/AccountExport";
import { PostsHelper } from "./PostsHelper";
import { CommentsHelper } from "./CommentsHelper";
/**
* Account helper
@ -389,7 +390,10 @@ export class AccountHelper {
userInfo: await UserHelper.GetUserInfo(userID),
// Export the list of posts
postsList: await PostsHelper.ExportAllPostsUser(userID)
postsList: await PostsHelper.ExportAllPostsUser(userID),
// Export the list of comments
comments: await CommentsHelper.ExportAllUser(userID)
})

View File

@ -158,6 +158,20 @@ export class CommentsHelper {
}
}
/**
* Get all the comments sent by a specified user
*
* @param userID Target user ID
*/
public static async ExportAllUser(userID: number) : Promise<Comment[]> {
return (await DatabaseHelper.Query({
table: COMMENTS_TABLE,
where: {
ID_personne: userID
}
})).map((row) => this.DbToComment(row));
}
/**
* Turn a database entry into a Comment object
*