From 6c4baf69ff6183710032e625bffb274b9f96040b Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 7 Jun 2017 01:20:07 +0900 Subject: WIP #161 --- src/api/common/watch-post.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/api/common') diff --git a/src/api/common/watch-post.ts b/src/api/common/watch-post.ts index 9f5e7a9130..1a50f0edaa 100644 --- a/src/api/common/watch-post.ts +++ b/src/api/common/watch-post.ts @@ -1,10 +1,15 @@ import * as mongodb from 'mongodb'; import Watching from '../models/post-watching'; -export default async (me: mongodb.ObjectID, post: mongodb.ObjectID) => { +export default async (me: mongodb.ObjectID, post: object) => { + // 自分の投稿はwatchできない + if (me.equals((post as any).user_id)) { + return; + } + // if watching now const exist = await Watching.findOne({ - post_id: post, + post_id: (post as any)._id, user_id: me, deleted_at: { $exists: false } }); @@ -15,7 +20,7 @@ export default async (me: mongodb.ObjectID, post: mongodb.ObjectID) => { await Watching.insert({ created_at: new Date(), - post_id: post, + post_id: (post as any)._id, user_id: me }); }; -- cgit v1.2.3-freya