mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-02 16:37:36 +01:00
wip
This commit is contained in:
parent
991635f919
commit
7b05e01819
3 changed files with 68 additions and 6 deletions
|
@ -1,12 +1,39 @@
|
||||||
import { ObjectID } from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import db from '../db/mongodb';
|
import db from '../db/mongodb';
|
||||||
|
|
||||||
const FollowedLog = db.get<IFollowedLog>('followedLogs');
|
const FollowedLog = db.get<IFollowedLog>('followedLogs');
|
||||||
export default FollowedLog;
|
export default FollowedLog;
|
||||||
|
|
||||||
export type IFollowedLog = {
|
export type IFollowedLog = {
|
||||||
_id: ObjectID;
|
_id: mongo.ObjectID;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
userId: ObjectID;
|
userId: mongo.ObjectID;
|
||||||
count: number;
|
count: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FollowedLogを物理削除します
|
||||||
|
*/
|
||||||
|
export async function deleteFollowedLog(followedLog: string | mongo.ObjectID | IFollowedLog) {
|
||||||
|
let f: IFollowedLog;
|
||||||
|
|
||||||
|
// Populate
|
||||||
|
if (mongo.ObjectID.prototype.isPrototypeOf(followedLog)) {
|
||||||
|
f = await FollowedLog.findOne({
|
||||||
|
_id: followedLog
|
||||||
|
});
|
||||||
|
} else if (typeof followedLog === 'string') {
|
||||||
|
f = await FollowedLog.findOne({
|
||||||
|
_id: new mongo.ObjectID(followedLog)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
f = followedLog as IFollowedLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f == null) return;
|
||||||
|
|
||||||
|
// このFollowedLogを削除
|
||||||
|
await FollowedLog.remove({
|
||||||
|
_id: f._id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -1,12 +1,39 @@
|
||||||
import { ObjectID } from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import db from '../db/mongodb';
|
import db from '../db/mongodb';
|
||||||
|
|
||||||
const FollowingLog = db.get<IFollowingLog>('followingLogs');
|
const FollowingLog = db.get<IFollowingLog>('followingLogs');
|
||||||
export default FollowingLog;
|
export default FollowingLog;
|
||||||
|
|
||||||
export type IFollowingLog = {
|
export type IFollowingLog = {
|
||||||
_id: ObjectID;
|
_id: mongo.ObjectID;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
userId: ObjectID;
|
userId: mongo.ObjectID;
|
||||||
count: number;
|
count: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FollowingLogを物理削除します
|
||||||
|
*/
|
||||||
|
export async function deleteFollowingLog(followingLog: string | mongo.ObjectID | IFollowingLog) {
|
||||||
|
let f: IFollowingLog;
|
||||||
|
|
||||||
|
// Populate
|
||||||
|
if (mongo.ObjectID.prototype.isPrototypeOf(followingLog)) {
|
||||||
|
f = await FollowingLog.findOne({
|
||||||
|
_id: followingLog
|
||||||
|
});
|
||||||
|
} else if (typeof followingLog === 'string') {
|
||||||
|
f = await FollowingLog.findOne({
|
||||||
|
_id: new mongo.ObjectID(followingLog)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
f = followingLog as IFollowingLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f == null) return;
|
||||||
|
|
||||||
|
// このFollowingLogを削除
|
||||||
|
await FollowingLog.remove({
|
||||||
|
_id: f._id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ import MessagingHistory, { deleteMessagingHistory } from './messaging-history';
|
||||||
import DriveFile, { deleteDriveFile } from './drive-file';
|
import DriveFile, { deleteDriveFile } from './drive-file';
|
||||||
import DriveFolder, { deleteDriveFolder } from './drive-folder';
|
import DriveFolder, { deleteDriveFolder } from './drive-folder';
|
||||||
import PollVote, { deletePollVote } from './poll-vote';
|
import PollVote, { deletePollVote } from './poll-vote';
|
||||||
|
import FollowingLog, { deleteFollowingLog } from './following-log';
|
||||||
|
import FollowedLog, { deleteFollowedLog } from './followed-log';
|
||||||
|
|
||||||
const User = db.get<IUser>('users');
|
const User = db.get<IUser>('users');
|
||||||
|
|
||||||
|
@ -228,8 +230,14 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
|
||||||
).map(x => deleteFollowing(x)));
|
).map(x => deleteFollowing(x)));
|
||||||
|
|
||||||
// このユーザーのFollowingLogをすべて削除
|
// このユーザーのFollowingLogをすべて削除
|
||||||
|
await Promise.all((
|
||||||
|
await FollowingLog.find({ userId: u._id })
|
||||||
|
).map(x => deleteFollowingLog(x)));
|
||||||
|
|
||||||
// このユーザーのFollowedLogをすべて削除
|
// このユーザーのFollowedLogをすべて削除
|
||||||
|
await Promise.all((
|
||||||
|
await FollowedLog.find({ userId: u._id })
|
||||||
|
).map(x => deleteFollowedLog(x)));
|
||||||
|
|
||||||
// このユーザーを削除
|
// このユーザーを削除
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue