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(l.el) } : { // In case of group type: "group", id: l.el, last_activity: l.lastActivity })); } }