From 77b7d18ef7f197e529b62bebf3363052be14caae Mon Sep 17 00:00:00 2001
From: Eduardo Mathias <ems19@inf.ufpr.br>
Date: Wed, 19 Jul 2023 10:59:20 -0300
Subject: [PATCH] [FIX] GET Filename

---
 src/libs/routes_v1/publication.js | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/libs/routes_v1/publication.js b/src/libs/routes_v1/publication.js
index 4b600c3d..1eff1f6b 100644
--- a/src/libs/routes_v1/publication.js
+++ b/src/libs/routes_v1/publication.js
@@ -107,9 +107,10 @@ pubApp.get('/:id', async (req, res, next) => {
     if(file_){
       publ.Filename = file_.name;
       }
-    res.json({ publication: publ });
+    req.result = publ;
+    next();
     }
-  });
+  }, response('publication'));
 
 pubApp.post('/', passport.authenticate('bearer', { session: false }), authorized('criar publicacao'), upload.single('file'), async (req, res, next) => {
   let _file_id = null
@@ -145,6 +146,17 @@ pubApp.post('/', passport.authenticate('bearer', { session: false }), authorized
   next();
 }, response('publication'));
 
+pubApp.post('/edit', passport.authenticate('bearer', { session: false }), authorized('editar publicacao'), upload.single('file'), async (req, res, next) => {
+  let _file_id = null
+  if(req.file){
+    _file_id = await fileWorker.uploadFile(req.file);
+    if(!_file_id)
+      console.log("NAO ARQUIVO");}
+  let data = JSON.parse(req.body.data);
+  req.result = data.toJSON();
+  next();
+}, response('publication'));
+
 pubApp.put('/edit/:id', passport.authenticate('bearer', { session: false }), authorized('editar publicacao'), async (req, res, next) => {
   console.log(req);
   let pb = await Publication.findByPk(req.params.id).catch(function (err) {
-- 
GitLab