diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index ae592d5..13d96cb 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -447,8 +447,11 @@ export class AccountHelper { // Delete all user comments await CommentsHelper.DeleteAllUser(userID); - */ + // Delete all user posts + await PostsHelper.DeleteAllUser(userID); + */ + // TODO : continue work } diff --git a/src/helpers/PostsHelper.ts b/src/helpers/PostsHelper.ts index b51c978..bb4f1eb 100644 --- a/src/helpers/PostsHelper.ts +++ b/src/helpers/PostsHelper.ts @@ -374,6 +374,19 @@ export class PostsHelper { return list.map((l) => this.DBToPost(l)); } + /** + * Delete all the posts of a given user + * + * This method deletes both the posts created by the user + * & the posts created on user page + * + * @param userID Target user ID + */ + public static async DeleteAllUser(userID: number) { + for(const post of await this.ExportAllPostsUser(userID)) + await this.Delete(post.id); + } + /** * Get the access level of a user over a post *