mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-15 13:25:44 +01:00
wip #1443
This commit is contained in:
parent
534ef9e999
commit
4166fd87c2
2 changed files with 67 additions and 1 deletions
|
@ -69,6 +69,38 @@ export type INote = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
export async function physicalDelete(note: string | mongo.ObjectID | INote) {
|
||||||
|
let n: INote;
|
||||||
|
|
||||||
|
// Populate
|
||||||
|
if (mongo.ObjectID.prototype.isPrototypeOf(note)) {
|
||||||
|
n = await Note.findOne({
|
||||||
|
_id: note
|
||||||
|
});
|
||||||
|
} else if (typeof note === 'string') {
|
||||||
|
n = await Note.findOne({
|
||||||
|
_id: new mongo.ObjectID(note)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
n = note as INote;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n == null) return;
|
||||||
|
|
||||||
|
// この投稿の返信をすべて削除
|
||||||
|
const replies = await Note.find({
|
||||||
|
replyId: n._id
|
||||||
|
});
|
||||||
|
await Promise.all(replies.map(r => physicalDelete(r)));
|
||||||
|
|
||||||
|
// この投稿のWatchをすべて削除
|
||||||
|
|
||||||
|
// この投稿のReactionをすべて削除
|
||||||
|
|
||||||
|
// この投稿に対するFavoriteをすべて削除
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pack a note for API response
|
* Pack a note for API response
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as mongo from 'mongodb';
|
||||||
import deepcopy = require('deepcopy');
|
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 { INote, pack as packNote } from './note';
|
import Note, { INote, pack as packNote, physicalDelete as physicalDeleteNote } from './note';
|
||||||
import Following from './following';
|
import Following from './following';
|
||||||
import Mute from './mute';
|
import Mute from './mute';
|
||||||
import getFriends from '../server/api/common/get-friends';
|
import getFriends from '../server/api/common/get-friends';
|
||||||
|
@ -121,6 +121,40 @@ export function init(user): IUser {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
export async function physicalDelete(user: string | mongo.ObjectID | IUser) {
|
||||||
|
let u: IUser;
|
||||||
|
|
||||||
|
// Populate
|
||||||
|
if (mongo.ObjectID.prototype.isPrototypeOf(user)) {
|
||||||
|
u = await User.findOne({
|
||||||
|
_id: user
|
||||||
|
});
|
||||||
|
} else if (typeof user === 'string') {
|
||||||
|
u = await User.findOne({
|
||||||
|
_id: new mongo.ObjectID(user)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
u = user as IUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (u == null) return;
|
||||||
|
|
||||||
|
// このユーザーが行った投稿をすべて削除
|
||||||
|
const notes = await Note.find({ userId: u._id });
|
||||||
|
await Promise.all(notes.map(n => physicalDeleteNote(n)));
|
||||||
|
|
||||||
|
// このユーザーのお気に入りをすべて削除
|
||||||
|
|
||||||
|
// このユーザーが行ったメッセージをすべて削除
|
||||||
|
|
||||||
|
// このユーザーのドライブのファイルをすべて削除
|
||||||
|
|
||||||
|
// このユーザーに関するfollowingをすべて削除
|
||||||
|
|
||||||
|
// このユーザーを削除
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pack a user for API response
|
* Pack a user for API response
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue