2019-10-17 16:59:18 +00:00
|
|
|
const routes = require('express').Router();
|
|
|
|
|
|
2022-03-21 16:39:56 +00:00
|
|
|
const { isAdministratorUser, isOptionalUser, isLoggedUser } = require('../../middlewares/accessValidator');
|
2019-10-17 16:59:18 +00:00
|
|
|
const SchemaValidator = require('../../middlewares/schemaValidator');
|
|
|
|
|
const PaginateMiddleware = require('../../middlewares/paginate');
|
|
|
|
|
const FieldMiddleware = require('../../middlewares/fields');
|
2019-10-31 12:45:18 +00:00
|
|
|
const SortMiddleware = require('../../middlewares/sort');
|
2019-10-17 16:59:18 +00:00
|
|
|
const notificationController = require('./notification.controller');
|
2019-11-07 17:24:29 +00:00
|
|
|
const { pushSendEvent, deviceTokenInputType } = require('./notification.validations');
|
2019-10-17 16:59:18 +00:00
|
|
|
|
|
|
|
|
const generalInvalidFields = [
|
|
|
|
|
'createdAt', 'updatedAt',
|
|
|
|
|
];
|
|
|
|
|
|
2019-10-31 12:45:18 +00:00
|
|
|
routes.get('/admin/notifications',
|
2019-10-17 16:59:18 +00:00
|
|
|
isAdministratorUser,
|
|
|
|
|
FieldMiddleware.middleware({
|
|
|
|
|
invalidFields: generalInvalidFields
|
|
|
|
|
}),
|
2019-10-31 12:45:18 +00:00
|
|
|
SortMiddleware.middleware({ default: "-date" }),
|
2019-10-17 16:59:18 +00:00
|
|
|
PaginateMiddleware.middleware(),
|
|
|
|
|
notificationController.find({
|
|
|
|
|
scopes: ['defaultScope']
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
2019-10-31 12:45:18 +00:00
|
|
|
routes.get('/admin/notifications/:id',
|
2019-10-17 16:59:18 +00:00
|
|
|
isAdministratorUser,
|
|
|
|
|
FieldMiddleware.middleware({
|
|
|
|
|
invalidFields: generalInvalidFields
|
|
|
|
|
}),
|
|
|
|
|
notificationController.findOne({
|
|
|
|
|
scopes: ['defaultScope']
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
2019-10-31 12:45:18 +00:00
|
|
|
routes.post('/admin/notifications',
|
2022-03-21 16:39:56 +00:00
|
|
|
isAdministratorUser,
|
2019-11-07 17:24:29 +00:00
|
|
|
SchemaValidator(pushSendEvent, true),
|
2019-10-17 16:59:18 +00:00
|
|
|
notificationController.sendNotification({
|
|
|
|
|
scopes: ['defaultScope']
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
2019-11-07 17:24:29 +00:00
|
|
|
/*routes.post('/admin/notifications/event',
|
2019-11-06 09:10:59 +00:00
|
|
|
isAdministratorUser,
|
2019-11-07 10:39:20 +00:00
|
|
|
SchemaValidator(pushSendEvent, true),
|
|
|
|
|
notificationController.sendNotificationEvent
|
2019-11-07 17:24:29 +00:00
|
|
|
);*/
|
2019-11-06 09:10:59 +00:00
|
|
|
|
2019-10-17 16:59:18 +00:00
|
|
|
/* Borrar cuando ya no aparezca la versión 1.0.10 */
|
2022-03-08 15:15:31 +00:00
|
|
|
/*routes.post('/notifications/register',
|
2019-10-17 16:59:18 +00:00
|
|
|
isLoggedUser,
|
|
|
|
|
SchemaValidator(deviceTokenInputType, true),
|
2019-10-21 10:12:16 +00:00
|
|
|
notificationController.registerDevice()
|
2022-03-08 15:15:31 +00:00
|
|
|
);*/
|
2019-10-17 16:59:18 +00:00
|
|
|
|
|
|
|
|
routes.post('/notifications/devices',
|
2022-03-21 16:39:56 +00:00
|
|
|
isOptionalUser,
|
2019-10-17 16:59:18 +00:00
|
|
|
SchemaValidator(deviceTokenInputType, true),
|
2019-10-21 10:12:16 +00:00
|
|
|
notificationController.registerDevice()
|
2019-10-17 16:59:18 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
module.exports = routes;
|