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/user.ts | |
| parent | Fix bug (diff) | |
| download | misskey-4166fd87c241f651932f99fd2909fa44acee4446.tar.gz misskey-4166fd87c241f651932f99fd2909fa44acee4446.tar.bz2 misskey-4166fd87c241f651932f99fd2909fa44acee4446.zip | |
wip #1443
Diffstat (limited to 'src/models/user.ts')
| -rw-r--r-- | src/models/user.ts | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/models/user.ts b/src/models/user.ts index adc9e6da99..a2800a3808 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -2,7 +2,7 @@ import * as mongo from 'mongodb'; import deepcopy = require('deepcopy'); import rap from '@prezzemolo/rap'; import db from '../db/mongodb'; -import { INote, pack as packNote } from './note'; +import Note, { INote, pack as packNote, physicalDelete as physicalDeleteNote } from './note'; import Following from './following'; import Mute from './mute'; import getFriends from '../server/api/common/get-friends'; @@ -121,6 +121,40 @@ export function init(user): IUser { return user; } +// TODO +export async function physicalDelete(user: string | mongo.ObjectID | IUser) { + let u: IUser; + + // Populate + if (mongo.ObjectID.prototype.isPrototypeOf(user)) { + u = await User.findOne({ + _id: user + }); + } else if (typeof user === 'string') { + u = await User.findOne({ + _id: new mongo.ObjectID(user) + }); + } else { + u = user as IUser; + } + + if (u == null) return; + + // このユーザーが行った投稿をすべて削除 + const notes = await Note.find({ userId: u._id }); + await Promise.all(notes.map(n => physicalDeleteNote(n))); + + // このユーザーのお気に入りをすべて削除 + + // このユーザーが行ったメッセージをすべて削除 + + // このユーザーのドライブのファイルをすべて削除 + + // このユーザーに関するfollowingをすべて削除 + + // このユーザーを削除 +} + /** * Pack a user for API response * |