mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-25 23:09:22 +00:00
Export groups memberships
This commit is contained in:
parent
89b5b3c4e1
commit
21a5e0df2e
@ -13,6 +13,8 @@ import { SurveyController } from "./SurveyController";
|
|||||||
import { MoviesController } from "./MoviesController";
|
import { MoviesController } from "./MoviesController";
|
||||||
import { ConversationsController } from "./ConversationsController";
|
import { ConversationsController } from "./ConversationsController";
|
||||||
import { FriendsController } from "./FriendsController";
|
import { FriendsController } from "./FriendsController";
|
||||||
|
import { GroupsHelper } from "../helpers/GroupsHelper";
|
||||||
|
import { GroupsController } from "./GroupsController";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account controller
|
* Account controller
|
||||||
@ -264,6 +266,10 @@ export class AccountController {
|
|||||||
// Friends list
|
// Friends list
|
||||||
friends_list: data.friendsList.map(f => FriendsController.FriendToAPI(f, false)),
|
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
|
// Related users info
|
||||||
users_info: new Map<number, any>(),
|
users_info: new Map<number, any>(),
|
||||||
};
|
};
|
||||||
|
@ -583,7 +583,7 @@ export class GroupsController {
|
|||||||
* in the request or not
|
* in the request or not
|
||||||
* @returns Generated object
|
* @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)
|
const membership = await GroupsHelper.GetMembershipInfo(info.id, h.optionnalUserID)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ export interface AccountExportBuilder {
|
|||||||
conversations: Conversation[];
|
conversations: Conversation[];
|
||||||
conversationsMessages: Map<number, ConversationMessage[]>;
|
conversationsMessages: Map<number, ConversationMessage[]>;
|
||||||
friendsList: Friend[];
|
friendsList: Friend[];
|
||||||
|
groups: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AccountExport implements AccountExportBuilder {
|
export class AccountExport implements AccountExportBuilder {
|
||||||
@ -41,6 +42,7 @@ export class AccountExport implements AccountExportBuilder {
|
|||||||
conversations: Conversation[];
|
conversations: Conversation[];
|
||||||
conversationsMessages: Map<number, ConversationMessage[]>;
|
conversationsMessages: Map<number, ConversationMessage[]>;
|
||||||
friendsList: Friend[];
|
friendsList: Friend[];
|
||||||
|
groups: number[];
|
||||||
|
|
||||||
public constructor(info: AccountExportBuilder) {
|
public constructor(info: AccountExportBuilder) {
|
||||||
for (const key in info) {
|
for (const key in info) {
|
||||||
|
@ -14,6 +14,7 @@ import { SurveyHelper } from "./SurveyHelper";
|
|||||||
import { MoviesHelper } from "./MoviesHelper";
|
import { MoviesHelper } from "./MoviesHelper";
|
||||||
import { ConversationsHelper } from "./ConversationsHelper";
|
import { ConversationsHelper } from "./ConversationsHelper";
|
||||||
import { FriendsHelper } from "./FriendsHelper";
|
import { FriendsHelper } from "./FriendsHelper";
|
||||||
|
import { GroupsHelper } from "./GroupsHelper";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account helper
|
* Account helper
|
||||||
@ -421,7 +422,8 @@ export class AccountHelper {
|
|||||||
// Friends
|
// Friends
|
||||||
friendsList: await FriendsHelper.GetList(userID),
|
friendsList: await FriendsHelper.GetList(userID),
|
||||||
|
|
||||||
// TODO : add groups list
|
// Groups membership
|
||||||
|
groups: await GroupsHelper.GetListUser(userID),
|
||||||
})
|
})
|
||||||
|
|
||||||
// Process conversation messages
|
// Process conversation messages
|
||||||
|
Loading…
Reference in New Issue
Block a user