From a9025aea0df014b77fa09073d6c51a8c20da632c Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 17 Apr 2019 02:51:12 +0900 Subject: [PATCH] Better response --- src/models/repositories/user.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts index 9e4247545a..30c77e78ca 100644 --- a/src/models/repositories/user.ts +++ b/src/models/repositories/user.ts @@ -84,6 +84,8 @@ export class UserRepository extends Repository { const pins = opts.detail ? await UserNotePinings.find({ userId: user.id }) : []; const profile = opts.detail ? await UserProfiles.findOne({ userId: user.id }).then(ensure) : null; + const falsy = opts.detail ? false : undefined; + return await rap({ id: user.id, name: user.name, @@ -91,10 +93,10 @@ export class UserRepository extends Repository { host: user.host, avatarUrl: user.avatarUrl ? user.avatarUrl : config.url + '/avatar/' + user.id, avatarColor: user.avatarColor, - isAdmin: user.isAdmin || undefined, - isBot: user.isBot || undefined, - isCat: user.isCat || undefined, - isVerified: user.isVerified || undefined, + isAdmin: user.isAdmin || falsy, + isBot: user.isBot || falsy, + isCat: user.isCat || falsy, + isVerified: user.isVerified || falsy, // カスタム絵文字添付 emojis: user.emojis.length > 0 ? Emojis.find({ @@ -123,7 +125,7 @@ export class UserRepository extends Repository { bannerUrl: user.bannerUrl, bannerColor: user.bannerColor, isLocked: user.isLocked, - isModerator: user.isModerator || undefined, + isModerator: user.isModerator || falsy, description: profile!.description, location: profile!.location, birthday: profile!.birthday,