From 0ef280377bbbd357bef688ab5c7fd609fd78af72 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 15 Apr 2018 06:34:55 +0900 Subject: wip --- src/models/user.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/models/user.ts') diff --git a/src/models/user.ts b/src/models/user.ts index 686bcc5ec5..56ca0c625f 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -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('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))); + // このユーザーを削除 } -- cgit v1.2.3-freya