APリファクタとLD-Signatureの検証に対応 (#6300)
* DbResolver * inbox types * 認証順を変更 * User/Keyあたりをまとめる * LD-Signatue * Validate contexts url * LD-Signature DocumentLoaderにProxyとTimeout
This commit is contained in:
@@ -1,22 +1,31 @@
|
||||
import { IRemoteUser } from '../../../../models/entities/user';
|
||||
import deleteNode from '../../../../services/note/delete';
|
||||
import { apLogger } from '../../logger';
|
||||
import { Notes } from '../../../../models';
|
||||
import DbResolver from '../../db-resolver';
|
||||
import { getApLock } from '../../../../misc/app-lock';
|
||||
|
||||
const logger = apLogger;
|
||||
|
||||
export default async function(actor: IRemoteUser, uri: string): Promise<void> {
|
||||
export default async function(actor: IRemoteUser, uri: string): Promise<string> {
|
||||
logger.info(`Deleting the Note: ${uri}`);
|
||||
|
||||
const note = await Notes.findOne({ uri });
|
||||
const unlock = await getApLock(uri);
|
||||
|
||||
if (note == null) {
|
||||
throw new Error('note not found');
|
||||
try {
|
||||
const dbResolver = new DbResolver();
|
||||
const note = await dbResolver.getNoteFromApId(uri);
|
||||
|
||||
if (note == null) {
|
||||
return 'note not found';
|
||||
}
|
||||
|
||||
if (note.userId !== actor.id) {
|
||||
return '投稿を削除しようとしているユーザーは投稿の作成者ではありません';
|
||||
}
|
||||
|
||||
await deleteNode(actor, note);
|
||||
return 'ok: deleted';
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
|
||||
if (note.userId !== actor.id) {
|
||||
throw new Error('投稿を削除しようとしているユーザーは投稿の作成者ではありません');
|
||||
}
|
||||
|
||||
await deleteNode(actor, note);
|
||||
}
|
||||
|
Reference in New Issue
Block a user