Skip to content

Commit

Permalink
images load to conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
ksydex committed Apr 10, 2020
1 parent ccd6d26 commit 942e9c0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 36 deletions.
69 changes: 35 additions & 34 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions controllers/user/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 942e9c0

Please sign in to comment.