summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-02-22 12:43:15 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-02-22 12:43:15 +0900
commitf2c5dc468c9bdb86e096565e9306f53eb1876ce0 (patch)
tree375cc71cb5d538541f8c9db8b80a615556a4d233 /src/api
parentClean up :sparkles: (diff)
downloadsharkey-f2c5dc468c9bdb86e096565e9306f53eb1876ce0.tar.gz
sharkey-f2c5dc468c9bdb86e096565e9306f53eb1876ce0.tar.bz2
sharkey-f2c5dc468c9bdb86e096565e9306f53eb1876ce0.zip
Extract user's profile
Diffstat (limited to 'src/api')
-rw-r--r--src/api/endpoints/i/update.js24
-rw-r--r--src/api/private/signup.ts16
2 files changed, 22 insertions, 18 deletions
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
}
});
diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts
index 2b679b914c..73e04f8b37 100644
--- a/src/api/private/signup.ts
+++ b/src/api/private/signup.ts
@@ -65,14 +65,12 @@ export default async (req: express.Request, res: express.Response) => {
token: secret,
avatar_id: null,
banner_id: null,
- birthday: null,
created_at: new Date(),
- bio: null,
+ description: null,
email: null,
followers_count: 0,
following_count: 0,
links: null,
- location: null,
name: name,
password: hash,
posts_count: 0,
@@ -80,7 +78,17 @@ export default async (req: express.Request, res: express.Response) => {
liked_count: 0,
drive_capacity: 1073741824, // 1GB
username: username,
- username_lower: username.toLowerCase()
+ username_lower: username.toLowerCase(),
+ profile: {
+ bio: null,
+ birthday: null,
+ blood: null,
+ gender: null,
+ handedness: null,
+ height: null,
+ location: null,
+ weight: null
+ }
});
// Response