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
113 lines
3.3 KiB
JavaScript
113 lines
3.3 KiB
JavaScript
import Users from 'meteor/nova:users';
|
|
import NovaEmail from 'meteor/nova:email';
|
|
|
|
// note: leverage weak dependencies on packages
|
|
const Comments = Package['nova:comments'] ? Package['nova:comments'].default : null;
|
|
const Posts = Package['nova:posts'] ? Package['nova:posts'].default : null;
|
|
|
|
const getTestUser = userId => typeof Users.findOne(userId) === "undefined" ? Users.findOne() : Users.findOne(userId);
|
|
|
|
NovaEmail.addEmails({
|
|
|
|
newUser: {
|
|
template: "newUser",
|
|
path: "/email/new-user/:_id?",
|
|
getProperties: Users.getNotificationProperties,
|
|
subject() {
|
|
return "A new user has been created";
|
|
},
|
|
getTestObject: getTestUser,
|
|
},
|
|
|
|
accountApproved: {
|
|
template: "accountApproved",
|
|
path: "/email/account-approved/:_id?",
|
|
getProperties: Users.getNotificationProperties,
|
|
subject() {
|
|
return "Your account has been approved.";
|
|
},
|
|
getTestObject: getTestUser,
|
|
}
|
|
|
|
});
|
|
|
|
if (!!Posts) {
|
|
|
|
const getTestPost = postId => typeof Posts.findOne(postId) === "undefined" ? {post: Posts.findOne()} : {post: Posts.findOne(postId)};
|
|
|
|
NovaEmail.addEmails({
|
|
|
|
newPost: {
|
|
template: "newPost",
|
|
path: "/email/new-post/:_id?",
|
|
getProperties: Posts.getNotificationProperties,
|
|
subject({postAuthorName="[postAuthorName]", postTitle="[postTitle]"}) {
|
|
return postAuthorName+' has created a new post: '+postTitle;
|
|
},
|
|
getTestObject: getTestPost,
|
|
},
|
|
|
|
newPendingPost: {
|
|
template: "newPendingPost",
|
|
path: "/email/new-pending-post/:_id?",
|
|
getProperties: Posts.getNotificationProperties,
|
|
subject({postAuthorName="[postAuthorName]", postTitle="[postTitle]"}) {
|
|
return postAuthorName+' has a new post pending approval: '+postTitle;
|
|
},
|
|
getTestObject: getTestPost,
|
|
},
|
|
|
|
postApproved: {
|
|
template: "postApproved",
|
|
path: "/email/post-approved/:_id?",
|
|
getProperties: Posts.getNotificationProperties,
|
|
subject({postTitle="[postTitle]"}) {
|
|
return 'Your post “'+postTitle+'” has been approved';
|
|
},
|
|
getTestObject: getTestPost,
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
if (!!Comments) {
|
|
|
|
const getTestComment = commentId => typeof Comments.findOne(commentId) === "undefined" ? {comment: Comments.findOne()} : {comment: Comments.findOne(commentId)};
|
|
|
|
NovaEmail.addEmails({
|
|
|
|
newComment: {
|
|
template: "newComment",
|
|
path: "/email/new-comment/:_id?",
|
|
getProperties: Comments.getNotificationProperties,
|
|
subject({authorName = "[authorName]", postTitle = "[postTitle]"}) {
|
|
return authorName+' left a new comment on your post "' + postTitle + '"';
|
|
},
|
|
getTestObject: getTestComment,
|
|
},
|
|
|
|
newReply: {
|
|
template: "newReply",
|
|
path: "/email/new-reply/:_id?",
|
|
getProperties: Comments.getNotificationProperties,
|
|
subject({authorName = "[authorName]", postTitle = "[postTitle]"}) {
|
|
return authorName+' replied to your comment on "'+postTitle+'"';
|
|
},
|
|
getTestObject: getTestComment,
|
|
},
|
|
|
|
newCommentSubscribed: {
|
|
template: "newComment",
|
|
path: "/email/new-comment-subscribed/:_id?",
|
|
getProperties: Comments.getNotificationProperties,
|
|
subject({authorName = "[authorName]", postTitle = "[postTitle]"}) {
|
|
return authorName+' left a new comment on "' + postTitle + '"';
|
|
},
|
|
getTestObject: getTestComment,
|
|
}
|
|
|
|
});
|
|
|
|
}
|