mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-26 15:29:22 +00:00
36 lines
875 B
TypeScript
36 lines
875 B
TypeScript
|
import { RequestHandler } from "../entities/RequestHandler";
|
||
|
import { WebappHelper } from "../helpers/WebappHelper";
|
||
|
import { UserMembershipType } from "../entities/UserMembershipEntry";
|
||
|
import { FriendsController } from "./FriendsController";
|
||
|
import { Friend } from "../entities/Friend";
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Web application controllers
|
||
|
*
|
||
|
* @author Pierre HUBERT
|
||
|
*/
|
||
|
export class WebAppControllers {
|
||
|
|
||
|
/**
|
||
|
* Get the memberships of the user
|
||
|
*
|
||
|
* @param h Request handler
|
||
|
*/
|
||
|
public static async GetMemberships(h: RequestHandler) {
|
||
|
|
||
|
const list = await WebappHelper.GetUserMemberships(h.getUserId());
|
||
|
|
||
|
h.send(list.map((l) => l.type == UserMembershipType.FRIEND ? {
|
||
|
// In case of friend
|
||
|
type: "friend",
|
||
|
friend: FriendsController.FriendToAPI(<Friend>l.el)
|
||
|
} : {
|
||
|
// In case of group
|
||
|
type: "group",
|
||
|
id: l.el,
|
||
|
last_activity: l.lastActivity
|
||
|
}));
|
||
|
}
|
||
|
|
||
|
}
|