From 85d3023cd5ee467f394d00657f3f2dffa14cdc62 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 13 Apr 2019 14:55:59 +0900 Subject: Clean packed responses --- src/models/repositories/note.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/models/repositories/note.ts') diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts index 77cf00849f..a2757d3cc8 100644 --- a/src/models/repositories/note.ts +++ b/src/models/repositories/note.ts @@ -162,15 +162,15 @@ export class NoteRepository extends Repository { const packed = await rap({ id: note.id, createdAt: note.createdAt, - app: note.appId ? Apps.pack(note.appId) : null, + app: note.appId ? Apps.pack(note.appId) : undefined, userId: note.userId, user: Users.pack(note.user || note.userId, meId), text: text, cw: note.cw, visibility: note.visibility, - localOnly: note.localOnly, - visibleUserIds: note.visibleUserIds, - viaMobile: note.viaMobile, + localOnly: note.localOnly || undefined, + visibleUserIds: note.visibility === 'specified' ? note.visibleUserIds : undefined, + viaMobile: note.viaMobile || undefined, renoteCount: note.renoteCount, repliesCount: note.repliesCount, reactions: note.reactions, @@ -188,13 +188,13 @@ export class NoteRepository extends Repository { ...(opts.detail ? { reply: note.replyId ? this.pack(note.replyId, meId, { detail: false - }) : null, + }) : undefined, renote: note.renoteId ? this.pack(note.renoteId, meId, { detail: true - }) : null, + }) : undefined, - poll: note.hasPoll ? populatePoll() : null, + poll: note.hasPoll ? populatePoll() : undefined, ...(meId ? { myReaction: populateMyReaction() -- cgit v1.2.3-freya