summaryrefslogtreecommitdiff
path: root/src/models/user.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-04-26 16:10:25 +0900
committerGitHub <noreply@github.com>2018-04-26 16:10:25 +0900
commit5d4b884528e0533e32b9c827ae8ccf64df0085dc (patch)
tree1f6a3238dfbf1f77da78d96e993f6d76cad73089 /src/models/user.ts
parentRefactor (diff)
parentwip (diff)
downloadmisskey-5d4b884528e0533e32b9c827ae8ccf64df0085dc.tar.gz
misskey-5d4b884528e0533e32b9c827ae8ccf64df0085dc.tar.bz2
misskey-5d4b884528e0533e32b9c827ae8ccf64df0085dc.zip
Merge pull request #1550 from syuilo/user-list
User list
Diffstat (limited to 'src/models/user.ts')
-rw-r--r--src/models/user.ts22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/models/user.ts b/src/models/user.ts
index ca1ca28937..0621b6e736 100644
--- a/src/models/user.ts
+++ b/src/models/user.ts
@@ -1,5 +1,6 @@
import * as mongo from 'mongodb';
import deepcopy = require('deepcopy');
+import sequential = require('promise-sequential');
import rap from '@prezzemolo/rap';
import db from '../db/mongodb';
import Note, { pack as packNote, deleteNote } from './note';
@@ -20,6 +21,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');
@@ -166,9 +168,9 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
).map(x => deleteAccessToken(x)));
// このユーザーのNoteをすべて削除
- await Promise.all((
- await Note.find({ userId: u._id })
- ).map(x => deleteNote(x)));
+ //await sequential((
+ // await Note.find({ userId: u._id })
+ //).map(x => () => deleteNote(x)));
// このユーザーのNoteReactionをすべて削除
await Promise.all((
@@ -260,6 +262,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