Post --> Note

Closes #1411
This commit is contained in:
syuilo
2018-04-08 02:30:37 +09:00
parent c7106d250c
commit a1b490afa7
167 changed files with 4440 additions and 1762 deletions

View File

@@ -0,0 +1,26 @@
import * as mongodb from 'mongodb';
import Watching from '../../models/note-watching';
export default async (me: mongodb.ObjectID, note: object) => {
// 自分の投稿はwatchできない
if (me.equals((note as any).userId)) {
return;
}
// if watching now
const exist = await Watching.findOne({
noteId: (note as any)._id,
userId: me,
deletedAt: { $exists: false }
});
if (exist !== null) {
return;
}
await Watching.insert({
createdAt: new Date(),
noteId: (note as any)._id,
userId: me
});
};