mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 12:36:39 -04:00

* Telescope.notifications.create -> import { createNotifications } from 'meteor/nova:notifications' ; * leverage Meteor's weak dependencies on packages & move code related to emails / notifications from nova:posts et al. to nova:notifications
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import Posts from '../collection.js'
|
|
import Users from 'meteor/nova:users';
|
|
import { addCallback } from 'meteor/nova:core';
|
|
|
|
// ------------------------------------- posts.remove.sync -------------------------------- //
|
|
|
|
function PostsRemoveOperations (post) {
|
|
Users.update({_id: post.userId}, {$inc: {"postCount": -1}});
|
|
}
|
|
addCallback("posts.remove.sync", PostsRemoveOperations);
|
|
|
|
// ------------------------------------- posts.approve.async -------------------------------- //
|
|
|
|
/**
|
|
* @summary set postedAt when a post is approved
|
|
*/
|
|
function PostsSetPostedAt (modifier, post) {
|
|
modifier.$set.postedAt = new Date();
|
|
return modifier;
|
|
}
|
|
addCallback("posts.approve.sync", PostsSetPostedAt);
|
|
|
|
|
|
// ------------------------------------- users.remove.async -------------------------------- //
|
|
|
|
function UsersRemoveDeletePosts (user, options) {
|
|
if (options.deletePosts) {
|
|
Posts.remove({userId: user._id});
|
|
} else {
|
|
// not sure if anything should be done in that scenario yet
|
|
// Posts.update({userId: userId}, {$set: {author: "\[deleted\]"}}, {multi: true});
|
|
}
|
|
}
|
|
addCallback("users.remove.async", UsersRemoveDeletePosts);
|