import { RequestHandler } from "../entities/RequestHandler"; import { NotificationsHelper } from "../helpers/NotificationsHelper"; import { ConversationsHelper } from "../helpers/ConversationsHelper"; import { FriendsHelper } from "../helpers/FriendsHelper"; /** * Notifications controller * * @author Pierre HUBERT */ export class NotificationsController { /** * Get the number of unread notifications * * @param h Request handler */ public static async CountUnread(h: RequestHandler) { h.send({ number: await NotificationsHelper.CountUnread(h.getUserId()) }); } /** * Count the entire number of unread notifications * * @param h Request handler */ public static async CountAllNews(h: RequestHandler) { let data = { notifications: await NotificationsHelper.CountUnread(h.getUserId()), conversations: await ConversationsHelper.CountUnreadForUser(h.getUserId()) } if(h.postBool("friends_request", false)) data["friends_requests"] = await FriendsHelper.CountRequests(h.getUserId()); // TODO : add pending calls h.send(data); } }