diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-11 18:24:42 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-11 18:24:42 +0900 |
| commit | 4166fd87c241f651932f99fd2909fa44acee4446 (patch) | |
| tree | 838914e262c0fca5737588a7bba64e2b9f3d8e5f /src/models/note.ts | |
| parent | Fix bug (diff) | |
| download | misskey-4166fd87c241f651932f99fd2909fa44acee4446.tar.gz misskey-4166fd87c241f651932f99fd2909fa44acee4446.tar.bz2 misskey-4166fd87c241f651932f99fd2909fa44acee4446.zip | |
wip #1443
Diffstat (limited to 'src/models/note.ts')
| -rw-r--r-- | src/models/note.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/models/note.ts b/src/models/note.ts index f509fa66c8..a11da196cd 100644 --- a/src/models/note.ts +++ b/src/models/note.ts @@ -69,6 +69,38 @@ export type INote = { }; }; +// TODO +export async function physicalDelete(note: string | mongo.ObjectID | INote) { + let n: INote; + + // Populate + if (mongo.ObjectID.prototype.isPrototypeOf(note)) { + n = await Note.findOne({ + _id: note + }); + } else if (typeof note === 'string') { + n = await Note.findOne({ + _id: new mongo.ObjectID(note) + }); + } else { + n = note as INote; + } + + if (n == null) return; + + // この投稿の返信をすべて削除 + const replies = await Note.find({ + replyId: n._id + }); + await Promise.all(replies.map(r => physicalDelete(r))); + + // この投稿のWatchをすべて削除 + + // この投稿のReactionをすべて削除 + + // この投稿に対するFavoriteをすべて削除 +} + /** * Pack a note for API response * |