1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/src/backend/middlewares/NotificationMWs.ts
2021-04-18 15:48:35 +02:00

23 lines
599 B
TypeScript

import {NextFunction, Request, Response} from 'express';
import {UserRoles} from '../../common/entities/UserDTO';
import {NotificationManager} from '../model/NotifocationManager';
export class NotificationMWs {
public static list(req: Request, res: Response, next: NextFunction): any {
if (req.session.user.role >= UserRoles.Admin) {
req.resultPipe = NotificationManager.notifications;
} else if (NotificationManager.notifications.length > 0) {
req.resultPipe = NotificationManager.HasNotification;
} else {
req.resultPipe = [];
}
return next();
}
}