diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-13 00:54:30 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-13 00:54:30 +0900 |
| commit | 719fac6480f8bd39498f2e92c83cac0fa26fb282 (patch) | |
| tree | e671e7b5e59777563f6799736a6d4a8fe45695e1 /src/models/note.ts | |
| parent | 10.10.1 (diff) | |
| download | sharkey-719fac6480f8bd39498f2e92c83cac0fa26fb282.tar.gz sharkey-719fac6480f8bd39498f2e92c83cac0fa26fb282.tar.bz2 sharkey-719fac6480f8bd39498f2e92c83cac0fa26fb282.zip | |
お気に入りを解除できるように
Diffstat (limited to 'src/models/note.ts')
| -rw-r--r-- | src/models/note.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/models/note.ts b/src/models/note.ts index a47fd098c7..e6bdbe0b8b 100644 --- a/src/models/note.ts +++ b/src/models/note.ts @@ -358,8 +358,8 @@ export const pack = async ( })(_note.poll); } - // Fetch my reaction if (meId) { + // Fetch my reaction _note.myReaction = (async () => { const reaction = await Reaction .findOne({ @@ -374,6 +374,19 @@ export const pack = async ( return null; })(); + + // isFavorited + _note.isFavorited = (async () => { + const favorite = await Favorite + .count({ + userId: meId, + noteId: id + }, { + limit: 1 + }); + + return favorite === 1; + })(); } } |