2016-03-17 16:34:36 +09:00
|
|
|
import Email from 'meteor/nova:email';
|
|
|
|
import Campaign from 'meteor/nova:newsletter';
|
|
|
|
|
2016-02-23 21:35:54 +09:00
|
|
|
// New post email
|
|
|
|
Picker.route('/email/new-post/:id?', function(params, req, res, next) {
|
|
|
|
var html;
|
|
|
|
var post = typeof params.id === "undefined" ? Posts.findOne() : Posts.findOne(params.id);
|
|
|
|
if (!!post) {
|
2016-03-17 16:34:36 +09:00
|
|
|
html = Email.getTemplate('newPost')(Posts.getNotificationProperties(post));
|
2016-02-23 21:35:54 +09:00
|
|
|
} else {
|
|
|
|
html = "<h3>No post found.</h3>"
|
|
|
|
}
|
2016-03-17 16:34:36 +09:00
|
|
|
res.end(Email.buildTemplate(html));
|
2016-02-23 21:35:54 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// Post approved
|
|
|
|
Picker.route('/email/post-approved/:id?', function(params, req, res, next) {
|
|
|
|
var html;
|
|
|
|
var post = typeof params.id === "undefined" ? Posts.findOne() : Posts.findOne(params.id);
|
|
|
|
if (!!post) {
|
2016-03-17 16:34:36 +09:00
|
|
|
html = Email.getTemplate('postApproved')(Posts.getNotificationProperties(post));
|
2016-02-23 21:35:54 +09:00
|
|
|
} else {
|
|
|
|
html = "<h3>No post found.</h3>"
|
|
|
|
}
|
2016-03-17 16:34:36 +09:00
|
|
|
res.end(Email.buildTemplate(html));
|
2016-02-23 21:35:54 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// New comment email
|
|
|
|
Picker.route('/email/new-comment/:id?', function(params, req, res, next) {
|
|
|
|
var html;
|
|
|
|
var comment = typeof params.id === "undefined" ? Comments.findOne() : Comments.findOne(params.id);
|
|
|
|
var post = Posts.findOne(comment.postId);
|
|
|
|
if (!!comment) {
|
2016-03-17 16:34:36 +09:00
|
|
|
html = Email.getTemplate('newComment')(Comments.getNotificationProperties(comment, post));
|
2016-02-23 21:35:54 +09:00
|
|
|
} else {
|
|
|
|
html = "<h3>No post found.</h3>"
|
|
|
|
}
|
2016-03-17 16:34:36 +09:00
|
|
|
res.end(Email.buildTemplate(html));
|
2016-02-23 21:35:54 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// New reply email
|
|
|
|
Picker.route('/email/new-reply/:id?', function(params, req, res, next) {
|
|
|
|
var html;
|
|
|
|
var comment = typeof params.id === "undefined" ? Comments.findOne() : Comments.findOne(params.id);
|
|
|
|
var post = Posts.findOne(comment.postId);
|
|
|
|
if (!!comment) {
|
2016-03-17 16:34:36 +09:00
|
|
|
html = Email.getTemplate('newReply')(Comments.getNotificationProperties(comment, post));
|
2016-02-23 21:35:54 +09:00
|
|
|
} else {
|
|
|
|
html = "<h3>No post found.</h3>"
|
|
|
|
}
|
2016-03-17 16:34:36 +09:00
|
|
|
res.end(Email.buildTemplate(html));
|
2016-02-23 21:35:54 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// New user email
|
|
|
|
Picker.route('/email/new-user/:id?', function(params, req, res, next) {
|
|
|
|
var html;
|
|
|
|
var user = typeof params.id === "undefined" ? Meteor.users.findOne() : Meteor.users.findOne(params.id);
|
|
|
|
var emailProperties = {
|
|
|
|
profileUrl: Users.getProfileUrl(user),
|
|
|
|
username: Users.getUserName(user)
|
|
|
|
};
|
2016-03-17 16:34:36 +09:00
|
|
|
html = Email.getTemplate('newUser')(emailProperties);
|
|
|
|
res.end(Email.buildTemplate(html));
|
2016-02-23 21:35:54 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// Account approved email
|
|
|
|
Picker.route('/email/account-approved/:id?', function(params, req, res, next) {
|
|
|
|
var user = typeof params.id === "undefined" ? Meteor.users.findOne() : Meteor.users.findOne(params.id);
|
|
|
|
var emailProperties = {
|
|
|
|
profileUrl: Users.getProfileUrl(user),
|
|
|
|
username: Users.getUserName(user),
|
|
|
|
siteTitle: Telescope.settings.get('title'),
|
|
|
|
siteUrl: Telescope.utils.getSiteUrl()
|
|
|
|
};
|
2016-03-17 16:34:36 +09:00
|
|
|
var html = Email.getTemplate('accountApproved')(emailProperties);
|
|
|
|
res.end(Email.buildTemplate(html));
|
2016-02-24 10:27:46 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
// Newsletter email
|
|
|
|
Picker.route('/email/newsletter', function(params, req, res, next) {
|
2016-03-17 16:34:36 +09:00
|
|
|
var campaign = Campaign.build(Campaign.getPosts(Telescope.settings.get('postsPerNewsletter', 5)));
|
2016-02-24 10:27:46 +09:00
|
|
|
var campaignSubject = '<div class="campaign-subject"><strong>Subject:</strong> '+campaign.subject+' (note: contents might change)</div>';
|
|
|
|
var campaignSchedule = '<div class="campaign-schedule"><strong>Scheduled for:</strong> '+ Meteor.call('getNextJob') +'</div>';
|
|
|
|
res.end(campaignSubject+campaignSchedule+campaign.html);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Newsletter confirmation email
|
|
|
|
Picker.route('/email/newsletter-confirmation', function(params, req, res, next) {
|
2016-03-17 16:34:36 +09:00
|
|
|
var confirmationHtml = Email.getTemplate('newsletterConfirmation')({
|
2016-02-24 10:27:46 +09:00
|
|
|
time: 'January 1st, 1901',
|
|
|
|
newsletterLink: 'http://example.com',
|
|
|
|
subject: 'Lorem ipsum dolor sit amet'
|
|
|
|
});
|
2016-03-17 16:34:36 +09:00
|
|
|
res.end(Email.buildTemplate(confirmationHtml));
|
2016-02-23 21:35:54 +09:00
|
|
|
});
|