From 942e9c0606ef0a335f794a40c4d9c89a874a5884 Mon Sep 17 00:00:00 2001 From: Artyom Date: Fri, 10 Apr 2020 14:05:19 +0300 Subject: [PATCH] images load to conversations --- .idea/workspace.xml | 69 ++++++++++++++++++++-------------------- controllers/user/Chat.js | 7 ++-- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c97cb3b..f709220 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,10 +1,9 @@ - + - - + @@ -53,7 +51,7 @@ - + @@ -196,14 +194,11 @@ - - - - 1583096359540 - 1583097152703 @@ -541,27 +536,32 @@ - - + - @@ -586,7 +586,8 @@ - @@ -597,26 +598,26 @@ - + - - + + - - + + - - + + - - + + - + @@ -665,14 +666,14 @@ - + - - + + - + diff --git a/controllers/user/Chat.js b/controllers/user/Chat.js index 7783540..2f96347 100644 --- a/controllers/user/Chat.js +++ b/controllers/user/Chat.js @@ -49,14 +49,17 @@ const Chat = { return utils.response.error(res, 'Ошибка загрузки сообщений') }, async uploadImage(req, res) { + const image = req.file + + if (req.body.to_user_id.indexOf('c') !== -1) + return utils.response.success(res, { src: image.filename }) + const toUserId = parseInt(req.body.to_user_id) const fromUserId = parseInt(req.currentUser.id) if (!req.file || typeof toUserId !== 'number') return utils.response.error(res) - const image = req.file - try { let access = false if (typeof req.currentUser.admin_role_id === 'number') access = true