mirror of
https://github.com/misskey-dev/misskey
synced 2024-12-18 08:38:52 +09:00
a1b490afa7
Closes #1411
27 lines
523 B
TypeScript
27 lines
523 B
TypeScript
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
|
|
});
|
|
};
|