mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-12-25 13:08:51 +00:00
Simplify response
This commit is contained in:
parent
f01c121bd4
commit
5ff3e53489
@ -281,7 +281,7 @@ export class AccountController {
|
||||
conversations_messages: {},
|
||||
|
||||
// Friends list
|
||||
friends_list: data.friendsList.map(f => FriendsController.FriendToAPI(f, false)),
|
||||
friends_list: data.friendsList.map(f => FriendsController.FriendToAPI(f)),
|
||||
|
||||
// Groups membership
|
||||
groups: await Promise.all((await Promise.all(data.groups.map(id => GroupsHelper.GetInfo(id))))
|
||||
|
@ -22,14 +22,14 @@ export class FriendsController {
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async GetList(h: RequestHandler) {
|
||||
const returnAllInfo = h.postBool("complete", false);
|
||||
//const returnAllInfo = h.postBool("complete", false);
|
||||
const list = await FriendsHelper.GetList(h.getUserId());
|
||||
|
||||
// Update user activity (if allowed)
|
||||
if(!h.postBool("incognito", false))
|
||||
await AccountHelper.UpdateLastActivity(h.getUserId())
|
||||
|
||||
h.send(list.map((f) => this.FriendToAPI(f, returnAllInfo)));
|
||||
h.send(list.map((f) => this.FriendToAPI(f)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +64,7 @@ export class FriendsController {
|
||||
if(info == null)
|
||||
h.error(404, "Requested frienship not found!");
|
||||
|
||||
h.send(this.FriendToAPI(info, true));
|
||||
h.send(this.FriendToAPI(info));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,24 +213,18 @@ export class FriendsController {
|
||||
* Turn a friend object into an API entry
|
||||
*
|
||||
* @param friend Friend object to transform
|
||||
* @param full Set to true to return all information
|
||||
*/
|
||||
public static FriendToAPI(friend: Friend, full: boolean = false) : any {
|
||||
let info: any = {
|
||||
public static FriendToAPI(friend: Friend) : any {
|
||||
return {
|
||||
ID_friend: friend.friendID,
|
||||
accepted: friend.accepted ? 1 : 0,
|
||||
time_last_activity:
|
||||
UserWebSocketController.IsConnected(friend.friendID) &&
|
||||
!UserWebSocketController.IsIcognito(friend.friendID)
|
||||
? time() : friend.lastActivityTime
|
||||
? time() : friend.lastActivityTime,
|
||||
following: friend.following ? 1 : 0,
|
||||
canPostTexts: friend.canPostTexts,
|
||||
}
|
||||
|
||||
if(full) {
|
||||
info.following = friend.following ? 1 : 0
|
||||
info.canPostTexts = friend.canPostTexts
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user