2018-03-31 03:30:30 +08:00
|
|
|
import {NextFunction, Request, Response} from 'express';
|
|
|
|
import {UserRoles} from '../../common/entities/UserDTO';
|
|
|
|
import {NotificationManager} from '../model/NotifocationManager';
|
|
|
|
|
|
|
|
const LOG_TAG = '[NotificationMWs]';
|
2017-07-09 20:23:50 +08:00
|
|
|
|
|
|
|
export class NotificationMWs {
|
|
|
|
|
|
|
|
|
|
|
|
public static list(req: Request, res: Response, next: NextFunction) {
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|