diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-09 05:02:52 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-09 05:02:52 +0900 |
| commit | 536277122d6c8f951114df6f7867095639343991 (patch) | |
| tree | 126de4e02c83b8cb126e82563959190f58f1fdfa /src/remote/activitypub/kernel/delete/note.ts | |
| parent | wip (diff) | |
| download | sharkey-536277122d6c8f951114df6f7867095639343991.tar.gz sharkey-536277122d6c8f951114df6f7867095639343991.tar.bz2 sharkey-536277122d6c8f951114df6f7867095639343991.zip | |
wip
Diffstat (limited to 'src/remote/activitypub/kernel/delete/note.ts')
| -rw-r--r-- | src/remote/activitypub/kernel/delete/note.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/remote/activitypub/kernel/delete/note.ts b/src/remote/activitypub/kernel/delete/note.ts new file mode 100644 index 0000000000..64c342d39b --- /dev/null +++ b/src/remote/activitypub/kernel/delete/note.ts @@ -0,0 +1,30 @@ +import * as debug from 'debug'; + +import Note from '../../../../models/note'; +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 note = await Note.findOne({ uri }); + + if (note == null) { + throw new Error('note not found'); + } + + if (!note.userId.equals(actor._id)) { + throw new Error('投稿を削除しようとしているユーザーは投稿の作成者ではありません'); + } + + Note.update({ _id: note._id }, { + $set: { + deletedAt: new Date(), + text: null, + textHtml: null, + mediaIds: [], + poll: null + } + }); +} |