2016-11-14 17:17:44 +09:00
|
|
|
import Comments from '../collection.js';
|
2016-12-13 11:40:24 +09:00
|
|
|
import { addCallback } from 'meteor/nova:core';
|
2016-11-14 17:17:44 +09:00
|
|
|
|
|
|
|
function UsersRemoveDeleteComments (user, options) {
|
|
|
|
if (options.deleteComments) {
|
|
|
|
var deletedComments = Comments.remove({userId: userId});
|
|
|
|
} else {
|
|
|
|
// not sure if anything should be done in that scenario yet
|
|
|
|
// Comments.update({userId: userId}, {$set: {author: "\[deleted\]"}}, {multi: true});
|
|
|
|
}
|
|
|
|
}
|
2016-12-13 11:40:24 +09:00
|
|
|
addCallback("users.remove.async", UsersRemoveDeleteComments);
|
2016-11-14 17:17:44 +09:00
|
|
|
|
|
|
|
// Add to posts.single publication
|
|
|
|
|
|
|
|
function PostsSingleAddCommentsUsers (users, post) {
|
|
|
|
// get IDs from all commenters on the post
|
|
|
|
const comments = Comments.find({postId: post._id}).fetch();
|
|
|
|
if (comments.length) {
|
|
|
|
users = users.concat(_.pluck(comments, "userId"));
|
|
|
|
}
|
|
|
|
return users;
|
|
|
|
}
|
2016-12-13 11:40:24 +09:00
|
|
|
addCallback("posts.single.getUsers", PostsSingleAddCommentsUsers);
|