2015-02-03 11:17:34 +09:00
|
|
|
|
|
|
|
var increasePostClicks = function(postId, ip){
|
2015-03-28 18:30:26 +09:00
|
|
|
|
2015-02-03 11:17:34 +09:00
|
|
|
var clickEvent = {
|
|
|
|
name: 'click',
|
|
|
|
properties: {
|
|
|
|
postId: postId,
|
|
|
|
ip: ip
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure this IP hasn't previously clicked on this post
|
|
|
|
var existingClickEvent = Events.findOne({name: 'click', 'properties.postId': postId, 'properties.ip': ip});
|
|
|
|
|
|
|
|
if(!existingClickEvent){
|
|
|
|
logEvent(clickEvent);
|
|
|
|
Posts.update(postId, { $inc: { clickCount: 1 }});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-17 14:45:23 +09:00
|
|
|
Meteor.startup(function (){
|
|
|
|
|
|
|
|
// Link Out
|
|
|
|
|
|
|
|
Router.route('/out', {
|
|
|
|
name: 'out',
|
|
|
|
where: 'server',
|
|
|
|
action: function(){
|
|
|
|
var query = this.request.query;
|
2015-01-06 09:32:27 +09:00
|
|
|
if(query.url){ // for some reason, query.url doesn't need to be decoded
|
|
|
|
var post = Posts.findOne({url: query.url});
|
2014-12-10 11:16:02 +09:00
|
|
|
if (post) {
|
2015-02-03 11:17:34 +09:00
|
|
|
var ip = this.request.connection.remoteAddress;
|
|
|
|
increasePostClicks(post._id, ip);
|
2014-12-10 11:16:02 +09:00
|
|
|
this.response.writeHead(302, {'Location': query.url});
|
|
|
|
} else {
|
|
|
|
// don't redirect if we can't find a post for that link
|
|
|
|
this.response.write('Invalid URL');
|
2014-11-17 14:45:23 +09:00
|
|
|
}
|
|
|
|
this.response.end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Account approved email
|
|
|
|
|
|
|
|
Router.route('/email/account-approved/:id?', {
|
|
|
|
name: 'accountApproved',
|
|
|
|
where: 'server',
|
|
|
|
action: function() {
|
|
|
|
var user = Meteor.users.findOne(this.params.id);
|
|
|
|
var emailProperties = {
|
2015-04-20 13:57:37 +09:00
|
|
|
profileUrl: Users.getProfileUrl(user),
|
|
|
|
username: Users.getUserName(user),
|
2015-03-28 18:30:26 +09:00
|
|
|
siteTitle: Settings.get('title'),
|
2015-04-20 13:57:37 +09:00
|
|
|
siteUrl: Telescope.utils.getSiteUrl()
|
2014-11-17 14:45:23 +09:00
|
|
|
};
|
2015-04-13 16:29:33 +09:00
|
|
|
html = Handlebars.templates['emailAccountApproved'](emailProperties);
|
2014-11-17 14:45:23 +09:00
|
|
|
this.response.write(buildEmailTemplate(html));
|
|
|
|
this.response.end();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-03-28 18:30:26 +09:00
|
|
|
});
|