summaryrefslogtreecommitdiff
path: root/src/remote/activitypub/act/delete/note.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-04-07 16:26:50 +0900
committerGitHub <noreply@github.com>2018-04-07 16:26:50 +0900
commit2547891f940a2872fcfb2b33cd33d4f7a42ca7bc (patch)
tree5cba4ae9cdfd63e7e1ef74a002a7b742183e8d3c /src/remote/activitypub/act/delete/note.ts
parentMerge pull request #1410 from akihikodaki/objec (diff)
parentRefactor (diff)
downloadmisskey-2547891f940a2872fcfb2b33cd33d4f7a42ca7bc.tar.gz
misskey-2547891f940a2872fcfb2b33cd33d4f7a42ca7bc.tar.bz2
misskey-2547891f940a2872fcfb2b33cd33d4f7a42ca7bc.zip
Merge pull request #1397 from syuilo/refactor
Refactor
Diffstat (limited to 'src/remote/activitypub/act/delete/note.ts')
-rw-r--r--src/remote/activitypub/act/delete/note.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/remote/activitypub/act/delete/note.ts b/src/remote/activitypub/act/delete/note.ts
new file mode 100644
index 0000000000..8e9447b481
--- /dev/null
+++ b/src/remote/activitypub/act/delete/note.ts
@@ -0,0 +1,30 @@
+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
+ }
+ });
+}