diff options
| author | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-04-02 17:11:14 +0900 |
|---|---|---|
| committer | Akihiko Odaki <nekomanma@pixiv.co.jp> | 2018-04-02 17:11:14 +0900 |
| commit | ce7efc4dbb9dca05b6b99b5ada22205890ca823f (patch) | |
| tree | 7889620f2172fef7277b66a7abb00557e966fbf3 /src/post/watch.ts | |
| parent | Introduce acct directory (diff) | |
| download | misskey-ce7efc4dbb9dca05b6b99b5ada22205890ca823f.tar.gz misskey-ce7efc4dbb9dca05b6b99b5ada22205890ca823f.tar.bz2 misskey-ce7efc4dbb9dca05b6b99b5ada22205890ca823f.zip | |
Distribute posts from remote
Diffstat (limited to 'src/post/watch.ts')
| -rw-r--r-- | src/post/watch.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/post/watch.ts b/src/post/watch.ts new file mode 100644 index 0000000000..61ea444430 --- /dev/null +++ b/src/post/watch.ts @@ -0,0 +1,26 @@ +import * as mongodb from 'mongodb'; +import Watching from '../models/post-watching'; + +export default async (me: mongodb.ObjectID, post: object) => { + // 自分の投稿はwatchできない + if (me.equals((post as any).userId)) { + return; + } + + // if watching now + const exist = await Watching.findOne({ + postId: (post as any)._id, + userId: me, + deletedAt: { $exists: false } + }); + + if (exist !== null) { + return; + } + + await Watching.insert({ + createdAt: new Date(), + postId: (post as any)._id, + userId: me + }); +}; |