This commit is contained in:
syuilo
2018-04-15 06:34:55 +09:00
parent 9c2f340c1e
commit 0ef280377b
3 changed files with 46 additions and 3 deletions

View File

@ -19,6 +19,7 @@ import PollVote, { deletePollVote } from './poll-vote';
import FollowingLog, { deleteFollowingLog } from './following-log';
import FollowedLog, { deleteFollowedLog } from './followed-log';
import SwSubscription, { deleteSwSubscription } from './sw-subscription';
import Notification, { deleteNotification } from './notification';
const User = db.get<IUser>('users');
@ -246,6 +247,16 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
await SwSubscription.find({ userId: u._id })
).map(x => deleteSwSubscription(x)));
// このユーザーのNotificationをすべて削除
await Promise.all((
await Notification.find({ notifieeId: u._id })
).map(x => deleteNotification(x)));
// このユーザーが原因となったNotificationをすべて削除
await Promise.all((
await Notification.find({ notifierId: u._id })
).map(x => deleteNotification(x)));
// このユーザーを削除
}