puyoskey/src/remote/activitypub/act/delete/note.ts
syuilo 494597236c 投稿に関しては論理削除するように
処理をシンプルにするため
2018-04-07 07:19:30 +09:00

30 lines
703 B
TypeScript

import * as debug from 'debug';
import Post from '../../../../models/post';
import { IRemoteUser } from '../../../../models/user';
const log = debug('misskey:activitypub');
export default async function(actor: IRemoteUser, uri: string): Promise<void> {
log(`Deleting the Note: ${uri}`);
const post = await Post.findOne({ uri });
if (post == null) {
throw new Error('post not found');
}
if (!post.userId.equals(actor._id)) {
throw new Error('投稿を削除しようとしているユーザーは投稿の作成者ではありません');
}
Post.update({ _id: post._id }, {
$set: {
deletedAt: new Date(),
text: null,
textHtml: null,
mediaIds: [],
poll: null
}
});
}