1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-22 05:19:22 +00:00

Export groups memberships

This commit is contained in:
Pierre HUBERT 2020-03-26 13:59:30 +01:00
parent 89b5b3c4e1
commit 21a5e0df2e
4 changed files with 12 additions and 2 deletions

View File

@ -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<number, any>(),
};

View File

@ -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<any> {
public static async GroupInfoToAPI(info: GroupInfo, h: RequestHandler, advanced: boolean = false) : Promise<any> {
const membership = await GroupsHelper.GetMembershipInfo(info.id, h.optionnalUserID)

View File

@ -27,6 +27,7 @@ export interface AccountExportBuilder {
conversations: Conversation[];
conversationsMessages: Map<number, ConversationMessage[]>;
friendsList: Friend[];
groups: number[];
}
export class AccountExport implements AccountExportBuilder {
@ -41,6 +42,7 @@ export class AccountExport implements AccountExportBuilder {
conversations: Conversation[];
conversationsMessages: Map<number, ConversationMessage[]>;
friendsList: Friend[];
groups: number[];
public constructor(info: AccountExportBuilder) {
for (const key in info) {

View File

@ -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