Vulcan/packages/nova-posts/lib/emails.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-06-23 12:17:39 +09:00
import Posts from './collection.js';
2016-06-23 16:42:06 +09:00
import NovaEmail from 'meteor/nova:email';
2016-06-23 11:40:35 +09:00
2016-04-13 12:34:41 +09:00
const getPost = (postId) => {
return typeof Posts.findOne(postId) === "undefined" ? {post: Posts.findOne()} : {post: Posts.findOne(postId)};
2016-04-13 12:34:41 +09:00
};
2016-06-23 16:42:06 +09:00
NovaEmail.addEmails({
2016-04-13 11:39:01 +09:00
newPost: {
template: "newPost",
path: "/email/new-post/:_id?",
getProperties: Posts.getNotificationProperties,
subject({postAuthorName="[postAuthorName]", postTitle="[postTitle]"}) {
return postAuthorName+' has created a new post: '+postTitle;
},
2016-04-13 12:34:41 +09:00
getTestObject: getPost
2016-04-13 11:39:01 +09:00
},
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;
},
2016-04-13 12:34:41 +09:00
getTestObject: getPost
2016-04-13 11:39:01 +09:00
},
postApproved: {
template: "postApproved",
path: "/email/post-approved/:_id?",
getProperties: Posts.getNotificationProperties,
subject({postTitle="[postTitle]"}) {
return 'Your post “'+postTitle+'” has been approved';
},
2016-04-13 12:34:41 +09:00
getTestObject: getPost
2016-04-13 11:39:01 +09:00
}
});