summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/models')
-rw-r--r--src/models/favorite.ts4
-rw-r--r--src/models/note.ts15
2 files changed, 17 insertions, 2 deletions
diff --git a/src/models/favorite.ts b/src/models/favorite.ts
index 4824a6dbaa..9acaec5c59 100644
--- a/src/models/favorite.ts
+++ b/src/models/favorite.ts
@@ -75,7 +75,9 @@ export const pack = (
delete _favorite._id;
// Populate note
- _favorite.note = await packNote(_favorite.noteId, me);
+ _favorite.note = await packNote(_favorite.noteId, me, {
+ detail: true
+ });
// (データベースの不具合などで)投稿が見つからなかったら
if (_favorite.note == null) {
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;
+ })();
}
}