Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

account/update-iconで画像が添付されていないときにエラーを出すように #1093

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/api/rest/account/update-icon.ls
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require! {

module.exports = (req, res) -> authorize req, res, (user, app) ->
[trim-x, trim-y, trim-w, trim-h] = get-express-params req, <[ trim-x trim-y trim-w trim-h ]>
if (Object.keys req.files).length == 1
if (Object.keys req.files).length >= 1 and req.files.image
path = req.files.image.path
image = fs.read-file-sync path
fs.unlink path
Expand All @@ -35,10 +35,12 @@ module.exports = (req, res) -> authorize req, res, (user, app) ->
res.api-error 500 'error'
else
update buffer, \jpg
else
res.api-error 400 'Not attached image'

function update(image, img-type)
register-image user, \user-icon, "#{user.id}.#{img-type}", img-type, image .then (path) ->
delete-image user, \user-icon, user.icon-image .then!
user.icon-image = path
user.save ->
res.api-render 'success'
res.api-render 'success'