From f2c5dc468c9bdb86e096565e9306f53eb1876ce0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Feb 2017 12:43:15 +0900 Subject: Extract user's profile --- src/api/endpoints/i/update.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src/api/endpoints/i') diff --git a/src/api/endpoints/i/update.js b/src/api/endpoints/i/update.js index 13b5c523e0..5aeafa60c8 100644 --- a/src/api/endpoints/i/update.js +++ b/src/api/endpoints/i/update.js @@ -39,7 +39,7 @@ module.exports = async (params, user, _, isSecure) => return rej('too long location'); } - user.location = location; + user.profile.location = location; } // Get 'bio' parameter @@ -49,21 +49,19 @@ module.exports = async (params, user, _, isSecure) => return rej('too long bio'); } - user.bio = bio; + user.profile.bio = bio; } // Get 'birthday' parameter const birthday = params.birthday; if (birthday != null) { - if (birthday != '') { - if (!isValidBirthday(birthday)) { - return rej('invalid birthday'); - } - - user.birthday = birthday; - } else { - user.birthday = null; + if (!isValidBirthday(birthday)) { + return rej('invalid birthday'); } + + user.profile.birthday = birthday; + } else { + user.profile.birthday = null; } // Get 'avatar_id' parameter @@ -81,11 +79,9 @@ module.exports = async (params, user, _, isSecure) => await User.update(user._id, { $set: { name: user.name, - location: user.location, - bio: user.bio, - birthday: user.birthday, avatar_id: user.avatar_id, - banner_id: user.banner_id + banner_id: user.banner_id, + profile: user.profile } }); -- cgit v1.2.3-freya