mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 05:19:22 +00:00
Export information about related users
This commit is contained in:
parent
aef43df39e
commit
dc79c42949
@ -231,7 +231,7 @@ export class AccountController {
|
|||||||
// Query the database
|
// Query the database
|
||||||
const data = await AccountHelper.Export(h.getUserId());
|
const data = await AccountHelper.Export(h.getUserId());
|
||||||
|
|
||||||
const out: any = {
|
const out = {
|
||||||
userID: data.userID,
|
userID: data.userID,
|
||||||
|
|
||||||
// General account information
|
// General account information
|
||||||
@ -262,7 +262,10 @@ export class AccountController {
|
|||||||
conversation_messages: {},
|
conversation_messages: {},
|
||||||
|
|
||||||
// Friends list
|
// Friends list
|
||||||
friends_list: data.friendsList.map(f => FriendsController.FriendToAPI(f, false))
|
friends_list: data.friendsList.map(f => FriendsController.FriendToAPI(f, false)),
|
||||||
|
|
||||||
|
// Related users info
|
||||||
|
users_info: new Map<number, any>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fill conversation messages entry
|
// Fill conversation messages entry
|
||||||
@ -272,7 +275,10 @@ export class AccountController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO : continue (additional user info)
|
// Load related users info
|
||||||
|
for(const id of await data.getRelatedUsersID()) {
|
||||||
|
out.users_info[id] = await UserController.UserToAPI(await UserHelper.GetUserInfo(id), h, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
h.send(out);
|
h.send(out);
|
||||||
|
@ -13,6 +13,7 @@ import { Movie } from "./Movie";
|
|||||||
import { ConversationMessage } from "./ConversationMessage";
|
import { ConversationMessage } from "./ConversationMessage";
|
||||||
import { Conversation } from "./Conversation";
|
import { Conversation } from "./Conversation";
|
||||||
import { Friend } from "./Friend";
|
import { Friend } from "./Friend";
|
||||||
|
import { CommentsHelper } from "../helpers/CommentsHelper";
|
||||||
|
|
||||||
export interface AccountExportBuilder {
|
export interface AccountExportBuilder {
|
||||||
userID: number;
|
userID: number;
|
||||||
@ -47,4 +48,37 @@ export class AccountExport implements AccountExportBuilder {
|
|||||||
this[key] = info[key];
|
this[key] = info[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ID of all the related users
|
||||||
|
*/
|
||||||
|
public async getRelatedUsersID() : Promise<Set<number>> {
|
||||||
|
const set = new Set<number>();
|
||||||
|
|
||||||
|
// Own user
|
||||||
|
set.add(this.userID);
|
||||||
|
|
||||||
|
// Friends
|
||||||
|
this.friendsList.forEach(f => set.add(f.friendID))
|
||||||
|
|
||||||
|
// Posts
|
||||||
|
for(const p of this.postsList) {
|
||||||
|
set.add(p.userID);
|
||||||
|
if(p.isUserPage) set.add(p.userPageID);
|
||||||
|
|
||||||
|
// Process post comments
|
||||||
|
(await CommentsHelper.Get(p.id)).forEach(c => set.add(c.userID))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comments
|
||||||
|
this.comments.forEach(c => set.add(c.userID))
|
||||||
|
|
||||||
|
// Conversation members
|
||||||
|
this.conversations.forEach(c => c.members.forEach(id => set.add(id)))
|
||||||
|
|
||||||
|
// Conversations messages
|
||||||
|
this.conversationsMessages.forEach(c => c.forEach(m => set.add(m.userID)))
|
||||||
|
|
||||||
|
return set;
|
||||||
|
}
|
||||||
}
|
}
|
@ -419,7 +419,9 @@ export class AccountHelper {
|
|||||||
conversationsMessages: new Map(),
|
conversationsMessages: new Map(),
|
||||||
|
|
||||||
// Friends
|
// Friends
|
||||||
friendsList: await FriendsHelper.GetList(userID)
|
friendsList: await FriendsHelper.GetList(userID),
|
||||||
|
|
||||||
|
// TODO : add groups list
|
||||||
})
|
})
|
||||||
|
|
||||||
// Process conversation messages
|
// Process conversation messages
|
||||||
@ -428,9 +430,6 @@ export class AccountHelper {
|
|||||||
= await ConversationsHelper.GetAllMessages(conv.id);
|
= await ConversationsHelper.GetAllMessages(conv.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO : continue
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user