This commit is contained in:
syuilo
2018-05-31 18:08:47 +09:00
parent 9fdb125960
commit 9599a31239
2 changed files with 71 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import FollowedLog, { deleteFollowedLog } from './followed-log';
import SwSubscription, { deleteSwSubscription } from './sw-subscription';
import Notification, { deleteNotification } from './notification';
import UserList, { deleteUserList } from './user-list';
import FollowRequest, { deleteFollowRequest } from './follow-requests';
const User = db.get<IUser>('users');
@ -50,7 +51,17 @@ type IUserBase = {
data: any;
description: string;
pinnedNoteId: mongo.ObjectID;
/**
* 凍結されているか否か
*/
isSuspended: boolean;
/**
* 鍵アカウントか否か
*/
isLocked: boolean;
host: string;
};
@ -240,6 +251,16 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
await Following.find({ followeeId: u._id })
).map(x => deleteFollowing(x)));
// このユーザーのFollowRequestをすべて削除
await Promise.all((
await FollowRequest.find({ followerId: u._id })
).map(x => deleteFollowRequest(x)));
// このユーザーへのFollowRequestをすべて削除
await Promise.all((
await FollowRequest.find({ followeeId: u._id })
).map(x => deleteFollowRequest(x)));
// このユーザーのFollowingLogをすべて削除
await Promise.all((
await FollowingLog.find({ userId: u._id })