Vulcan/lib/post.js

23 lines
501 B
JavaScript
Raw Normal View History

Meteor.methods({
post: function(post){
2012-10-04 11:53:15 +10:00
var user = Meteor.user();
if (!user || !user.approved)
throw new Meteor.Error('You need to login and be approved to post new stories.')
post = _.extend(post, {
2012-10-04 11:53:15 +10:00
userId: user._id,
author: user.username,
submitted: new Date().getTime(),
votes: 0,
comments: 0,
baseScore: 0,
score: 0
});
2012-10-04 15:26:59 +09:00
var postId=Posts.insert(post);
Meteor.call('upvotePost', postId);
return postId;
}
});