2018-04-06 23:44:29 +02:00
|
|
|
import * as debug from 'debug';
|
|
|
|
|
2018-04-06 12:35:23 +02:00
|
|
|
import Post from '../../../../models/post';
|
|
|
|
import { createDb } from '../../../../queue';
|
|
|
|
|
2018-04-06 23:44:29 +02:00
|
|
|
const log = debug('misskey:activitypub');
|
|
|
|
|
2018-04-06 23:51:35 +02:00
|
|
|
export default async function(actor, uri: string) {
|
2018-04-06 23:44:29 +02:00
|
|
|
log(`Deleting the Note: ${uri}`);
|
|
|
|
|
2018-04-06 23:51:35 +02:00
|
|
|
const post = await Post.findOne({ uri });
|
|
|
|
|
|
|
|
if (post == null) {
|
|
|
|
throw new Error('post not found');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (post.userId !== actor._id) {
|
|
|
|
throw new Error('投稿を削除しようとしているユーザーは投稿の作成者ではありません');
|
|
|
|
}
|
|
|
|
|
|
|
|
Post.remove({ _id: post._id });
|
2018-04-06 12:35:23 +02:00
|
|
|
|
|
|
|
createDb({
|
|
|
|
type: 'deletePostDependents',
|
|
|
|
id: post._id
|
|
|
|
}).delay(65536).save();
|
|
|
|
}
|