summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-04-13 14:55:59 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-04-13 14:55:59 +0900
commit85d3023cd5ee467f394d00657f3f2dffa14cdc62 (patch)
tree8e5379bb89ab6f557c1d0cfb0e7cf0480a0e23a0 /src/models
parentAdd note (diff)
downloadsharkey-85d3023cd5ee467f394d00657f3f2dffa14cdc62.tar.gz
sharkey-85d3023cd5ee467f394d00657f3f2dffa14cdc62.tar.bz2
sharkey-85d3023cd5ee467f394d00657f3f2dffa14cdc62.zip
Clean packed responses
Diffstat (limited to 'src/models')
-rw-r--r--src/models/repositories/note.ts14
-rw-r--r--src/models/repositories/user.ts8
2 files changed, 11 insertions, 11 deletions
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<Note> {
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<Note> {
...(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()
diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts
index cddb77ffae..fb11778324 100644
--- a/src/models/repositories/user.ts
+++ b/src/models/repositories/user.ts
@@ -92,10 +92,10 @@ export class UserRepository extends Repository<User> {
bannerUrl: user.bannerUrl,
avatarColor: user.avatarColor,
bannerColor: user.bannerColor,
- isAdmin: user.isAdmin,
- isBot: user.isBot,
- isCat: user.isCat,
- isVerified: user.isVerified,
+ isAdmin: user.isAdmin || undefined,
+ isBot: user.isBot || undefined,
+ isCat: user.isCat || undefined,
+ isVerified: user.isVerified || undefined,
// カスタム絵文字添付
emojis: user.emojis.length > 0 ? Emojis.find({