This commit is contained in:
syuilo
2018-04-24 10:08:15 +09:00
parent 9e74a3b8fa
commit 03c824f893
2 changed files with 55 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import FollowingLog, { deleteFollowingLog } from './following-log';
import FollowedLog, { deleteFollowedLog } from './followed-log';
import SwSubscription, { deleteSwSubscription } from './sw-subscription';
import Notification, { deleteNotification } from './notification';
import UserList, { deleteUserList } from './user-list';
const User = db.get<IUser>('users');
@ -260,6 +261,20 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
await Notification.find({ notifierId: u._id })
).map(x => deleteNotification(x)));
// このユーザーのUserListをすべて削除
await Promise.all((
await UserList.find({ userId: u._id })
).map(x => deleteUserList(x)));
// このユーザーの入っているすべてのUserListからこのユーザーを削除
await Promise.all((
await UserList.find({ userIds: u._id })
).map(x =>
UserList.update({ _id: x._id }, {
$pull: { userIds: u._id }
})
));
// このユーザーを削除
await User.remove({
_id: u._id