This commit is contained in:
syuilo
2018-04-04 23:12:35 +09:00
parent b60121527d
commit e8b42d7e16
20 changed files with 354 additions and 377 deletions

View File

@@ -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 })
]))
]);

View File

@@ -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);