Distribute posts from remote

This commit is contained in:
Akihiko Odaki
2018-04-02 17:11:14 +09:00
parent aa94035987
commit ce7efc4dbb
12 changed files with 417 additions and 353 deletions

View File

@ -1,26 +0,0 @@
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
});
};