This commit is contained in:
syuilo
2018-04-12 04:05:03 +09:00
parent 553fccd719
commit 92dd4b3e5a
3 changed files with 73 additions and 5 deletions

View File

@ -11,6 +11,8 @@ import AccessToken, { deleteAccessToken } from './access-token';
import NoteWatching, { deleteNoteWatching } from './note-watching';
import Favorite, { deleteFavorite } from './favorite';
import NoteReaction, { deleteNoteReaction } from './note-reaction';
import MessagingMessage, { deleteMessagingMessage } from './messaging-message';
import MessagingHistory, { deleteMessagingHistory } from './messaging-history';
const User = db.get<IUser>('users');
@ -173,8 +175,19 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
).map(x => deleteFavorite(x)));
// このユーザーのMessageをすべて削除
await Promise.all((
await MessagingMessage.find({ userId: u._id })
).map(x => deleteMessagingMessage(x)));
// このユーザーへのMessageをすべて削除
await Promise.all((
await MessagingMessage.find({ recipientId: u._id })
).map(x => deleteMessagingMessage(x)));
// このユーザーの関わるMessagingHistoryをすべて削除
await Promise.all((
await MessagingHistory.find({ $or: [{ partnerId: u._id }, { userId: u._id }] })
).map(x => deleteMessagingHistory(x)));
// このユーザーのDriveFileをすべて削除