summaryrefslogtreecommitdiff
path: root/src/processor/db
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-04-04 00:25:42 +0900
committerGitHub <noreply@github.com>2018-04-04 00:25:42 +0900
commitb4ebf4033f553d068cad494402aa675193d09fa3 (patch)
tree8dfdd27810c5112d1bd26e3d65575d16e670ac28 /src/processor/db
parentMerge pull request #1387 from akihikodaki/duplicate (diff)
parentImplement Delete activity (diff)
downloadmisskey-b4ebf4033f553d068cad494402aa675193d09fa3.tar.gz
misskey-b4ebf4033f553d068cad494402aa675193d09fa3.tar.bz2
misskey-b4ebf4033f553d068cad494402aa675193d09fa3.zip
Merge pull request #1388 from akihikodaki/duplicate
Implement Delete activity
Diffstat (limited to 'src/processor/db')
-rw-r--r--src/processor/db/delete-post-dependents.ts22
-rw-r--r--src/processor/db/index.ts7
2 files changed, 29 insertions, 0 deletions
diff --git a/src/processor/db/delete-post-dependents.ts b/src/processor/db/delete-post-dependents.ts
new file mode 100644
index 0000000000..879c41ec9c
--- /dev/null
+++ b/src/processor/db/delete-post-dependents.ts
@@ -0,0 +1,22 @@
+import Favorite from '../../models/favorite';
+import Notification from '../../models/notification';
+import PollVote from '../../models/poll-vote';
+import PostReaction from '../../models/post-reaction';
+import PostWatching from '../../models/post-watching';
+import Post from '../../models/post';
+
+export default async ({ data }) => Promise.all([
+ Favorite.remove({ postId: data._id }),
+ Notification.remove({ postId: data._id }),
+ PollVote.remove({ postId: data._id }),
+ PostReaction.remove({ postId: data._id }),
+ PostWatching.remove({ postId: data._id }),
+ Post.find({ repostId: data._id }).then(reposts => Promise.all([
+ Notification.remove({
+ postId: {
+ $in: reposts.map(({ _id }) => _id)
+ }
+ }),
+ Post.remove({ repostId: data._id })
+ ]))
+]);
diff --git a/src/processor/db/index.ts b/src/processor/db/index.ts
new file mode 100644
index 0000000000..75838c099b
--- /dev/null
+++ b/src/processor/db/index.ts
@@ -0,0 +1,7 @@
+import deletePostDependents from './delete-post-dependents';
+
+const handlers = {
+ deletePostDependents
+};
+
+export default (job, done) => handlers[job.data.type](job).then(() => done(), done);