summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-12 05:50:45 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-12 05:50:45 +0900
commitb846eb8afe0376feacb567e86bf157b8fd5f4c36 (patch)
tree3753f96440687cd28c53d3efde79ab4888fcbb86 /src/models
parentwip (diff)
downloadmisskey-b846eb8afe0376feacb567e86bf157b8fd5f4c36.tar.gz
misskey-b846eb8afe0376feacb567e86bf157b8fd5f4c36.tar.bz2
misskey-b846eb8afe0376feacb567e86bf157b8fd5f4c36.zip
wip
Diffstat (limited to 'src/models')
-rw-r--r--src/models/mute.ts27
-rw-r--r--src/models/user.ts16
2 files changed, 42 insertions, 1 deletions
diff --git a/src/models/mute.ts b/src/models/mute.ts
index 8793615967..e068215c94 100644
--- a/src/models/mute.ts
+++ b/src/models/mute.ts
@@ -11,3 +11,30 @@ export interface IMute {
muterId: mongo.ObjectID;
muteeId: mongo.ObjectID;
}
+
+/**
+ * Muteを物理削除します
+ */
+export async function deleteMute(mute: string | mongo.ObjectID | IMute) {
+ let m: IMute;
+
+ // Populate
+ if (mongo.ObjectID.prototype.isPrototypeOf(mute)) {
+ m = await Mute.findOne({
+ _id: mute
+ });
+ } else if (typeof mute === 'string') {
+ m = await Mute.findOne({
+ _id: new mongo.ObjectID(mute)
+ });
+ } else {
+ m = mute as IMute;
+ }
+
+ if (m == null) return;
+
+ // このMuteを削除
+ await Mute.remove({
+ _id: m._id
+ });
+}
diff --git a/src/models/user.ts b/src/models/user.ts
index b56cf03ef8..ff1c11e76c 100644
--- a/src/models/user.ts
+++ b/src/models/user.ts
@@ -4,7 +4,7 @@ import rap from '@prezzemolo/rap';
import db from '../db/mongodb';
import Note, { INote, pack as packNote, deleteNote } from './note';
import Following from './following';
-import Mute from './mute';
+import Mute, { deleteMute } from './mute';
import getFriends from '../server/api/common/get-friends';
import config from '../config';
import AccessToken, { deleteAccessToken } from './access-token';
@@ -201,10 +201,24 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
await DriveFolder.find({ userId: u._id })
).map(x => deleteDriveFolder(x)));
+ // このユーザーのMuteをすべて削除
+ await Promise.all((
+ await Mute.find({ muterId: u._id })
+ ).map(x => deleteMute(x)));
+
+ // このユーザーへのMuteをすべて削除
+ await Promise.all((
+ await Mute.find({ muteeId: u._id })
+ ).map(x => deleteMute(x)));
+
// このユーザーのFollowingをすべて削除
// このユーザーへのFollowingをすべて削除
+ // このユーザーのFollowingLogをすべて削除
+
+ // このユーザーのFollowedLogをすべて削除
+
// このユーザーを削除
}