mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 00:25:17 +00:00
Export the list of posts of the user
This commit is contained in:
@ -7,6 +7,7 @@ import { time, mysql_date } from "../utils/DateUtils";
|
||||
import { NewAccount } from "../entities/NewAccount";
|
||||
import { GeneralSettings, UserPageStatus, LangSettings, SecuritySettings } from "../entities/User";
|
||||
import { AccountExport } from "../entities/AccountExport";
|
||||
import { PostsHelper } from "./PostsHelper";
|
||||
|
||||
/**
|
||||
* Account helper
|
||||
@ -383,8 +384,12 @@ export class AccountHelper {
|
||||
*/
|
||||
public static async Export(userID: number) : Promise<AccountExport> {
|
||||
const data = new AccountExport({
|
||||
// General info
|
||||
userID: userID,
|
||||
userInfo: await UserHelper.GetUserInfo(userID)
|
||||
userInfo: await UserHelper.GetUserInfo(userID),
|
||||
|
||||
// Export the list of posts
|
||||
postsList: await PostsHelper.ExportAllPostsUser(userID)
|
||||
})
|
||||
|
||||
|
||||
|
@ -338,6 +338,26 @@ export class PostsHelper {
|
||||
return this.DBToPost(row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entire list of posts created by a user &
|
||||
* the posts on user page
|
||||
*
|
||||
* This function does not care about visibility levels & does not
|
||||
* have any limit
|
||||
*
|
||||
* @param userID Target user ID
|
||||
*/
|
||||
public static async ExportAllPostsUser(userID: number) : Promise<Post[]> {
|
||||
const list = await DatabaseHelper.Query({
|
||||
table: TABLE_NAME,
|
||||
|
||||
customWhere: "ID_personne = ? OR ID_amis = ?",
|
||||
customWhereArgs: [userID.toString(), userID.toString()]
|
||||
});
|
||||
|
||||
return list.map((l) => this.DBToPost(l));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the access level of a user over a post
|
||||
*
|
||||
|
Reference in New Issue
Block a user