summaryrefslogtreecommitdiff
path: root/src/api/common
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-06-07 01:20:07 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-06-07 01:20:07 +0900
commit6c4baf69ff6183710032e625bffb274b9f96040b (patch)
treeded9d74505d8e2288dacb430d71a16042ee92fbe /src/api/common
parentWIP #161 (diff)
downloadsharkey-6c4baf69ff6183710032e625bffb274b9f96040b.tar.gz
sharkey-6c4baf69ff6183710032e625bffb274b9f96040b.tar.bz2
sharkey-6c4baf69ff6183710032e625bffb274b9f96040b.zip
WIP #161
Diffstat (limited to 'src/api/common')
-rw-r--r--src/api/common/watch-post.ts11
1 files changed, 8 insertions, 3 deletions
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
});
};