mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 08:35:17 +00:00
Can count all new elements
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
import { RequestHandler } from "../entities/RequestHandler";
|
||||
import { NotificationsHelper } from "../helpers/NotificationsHelper";
|
||||
import { ConversationsHelper } from "../helpers/ConversationsHelper";
|
||||
import { FriendsHelper } from "../helpers/FriendsHelper";
|
||||
|
||||
/**
|
||||
* Notifications controller
|
||||
@ -20,4 +22,22 @@ export class NotificationsController {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
@ -136,4 +136,6 @@ export const Routes : Route[] = [
|
||||
|
||||
// Notifications controller
|
||||
{path: "/notifications/count_unread", cb: (h) => NotificationsController.CountUnread(h)},
|
||||
|
||||
{path: "/notifications/count_all_news", cb: (h) => NotificationsController.CountAllNews(h)},
|
||||
]
|
Reference in New Issue
Block a user