1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- const express = require('express');
- const router = express.Router();
- const guard = require('../helpers/guard');
- const controllers = require('../controllers/messages');
- const validation = require('../validation/message');
- const upload = require('../helpers/upload');
- router
- .get('/', guard, controllers.listMessages)
- .post('/', guard, validation.sentMessage, controllers.sentMessage)
- .post('/reply/', guard, validation.sentMessage, controllers.sentMessageReply)
- .post('/edit/', guard, validation.editMessage, controllers.editMessage)
- .post(
- '/forward/',
- guard,
- validation.sentForwardMessage,
- controllers.sentMessageForward
- )
- .patch(
- '/selected/',
- guard,
- validation.removeSelected,
- controllers.removeSelected
- )
- .patch('/unpin/all/', guard, validation.unpinAll, controllers.unpinAllMessage)
- .post(
- '/image/:companionIdAndCaption',
- [guard, upload.uploadImage.single('image'), validation.validateUploadFile],
- controllers.imageMessage
- )
- .post(
- '/audio/:companionIdAndCaption',
- [guard, upload.uploadAudio.single('audio'), validation.validateUploadFile],
- controllers.audioMessage
- )
- .post(
- '/video/:companionIdAndCaption',
- [guard, upload.uploadVideo.single('video'), validation.validateUploadFile],
- controllers.videoMessage
- )
- .post(
- '/file/:companionIdAndCaption',
- [guard, upload.uploadFile.single('file'), validation.validateUploadFile],
- controllers.fileMessage
- );
- router
- .get('/:companionId', guard, controllers.listMessagesById)
- .patch('/pin/:id', guard, controllers.updateMessagePin)
- .patch('/:id', guard, controllers.updateMessageEmoji)
- .delete('/:id', guard, controllers.removeMessage);
- module.exports = router;
|