mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-11-25 07:36:18 +09:00
wip
This commit is contained in:
parent
9714b06f56
commit
37c5fc5ca3
@ -11,3 +11,30 @@ export type IFollowing = {
|
|||||||
followeeId: mongo.ObjectID;
|
followeeId: mongo.ObjectID;
|
||||||
followerId: mongo.ObjectID;
|
followerId: mongo.ObjectID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Followingを物理削除します
|
||||||
|
*/
|
||||||
|
export async function deleteFollowing(following: string | mongo.ObjectID | IFollowing) {
|
||||||
|
let f: IFollowing;
|
||||||
|
|
||||||
|
// Populate
|
||||||
|
if (mongo.ObjectID.prototype.isPrototypeOf(following)) {
|
||||||
|
f = await Following.findOne({
|
||||||
|
_id: following
|
||||||
|
});
|
||||||
|
} else if (typeof following === 'string') {
|
||||||
|
f = await Following.findOne({
|
||||||
|
_id: new mongo.ObjectID(following)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
f = following as IFollowing;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f == null) return;
|
||||||
|
|
||||||
|
// このFollowingを削除
|
||||||
|
await Following.remove({
|
||||||
|
_id: f._id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@ import deepcopy = require('deepcopy');
|
|||||||
import rap from '@prezzemolo/rap';
|
import rap from '@prezzemolo/rap';
|
||||||
import db from '../db/mongodb';
|
import db from '../db/mongodb';
|
||||||
import Note, { INote, pack as packNote, deleteNote } from './note';
|
import Note, { INote, pack as packNote, deleteNote } from './note';
|
||||||
import Following from './following';
|
import Following, { deleteFollowing } from './following';
|
||||||
import Mute, { deleteMute } from './mute';
|
import Mute, { deleteMute } from './mute';
|
||||||
import getFriends from '../server/api/common/get-friends';
|
import getFriends from '../server/api/common/get-friends';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
@ -212,8 +212,14 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
|
|||||||
).map(x => deleteMute(x)));
|
).map(x => deleteMute(x)));
|
||||||
|
|
||||||
// このユーザーのFollowingをすべて削除
|
// このユーザーのFollowingをすべて削除
|
||||||
|
await Promise.all((
|
||||||
|
await Following.find({ followerId: u._id })
|
||||||
|
).map(x => deleteFollowing(x)));
|
||||||
|
|
||||||
// このユーザーへのFollowingをすべて削除
|
// このユーザーへのFollowingをすべて削除
|
||||||
|
await Promise.all((
|
||||||
|
await Following.find({ followeeId: u._id })
|
||||||
|
).map(x => deleteFollowing(x)));
|
||||||
|
|
||||||
// このユーザーのFollowingLogをすべて削除
|
// このユーザーのFollowingLogをすべて削除
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user