mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 04:16:37 -04:00
27 lines
No EOL
560 B
JavaScript
27 lines
No EOL
560 B
JavaScript
Meteor.methods({
|
|
post: function(post){
|
|
var user = Meteor.user();
|
|
|
|
if (!user || !canPost(user))
|
|
throw new Meteor.Error('You need to login or be invited to post new stories.')
|
|
|
|
if(!this.isSimulation)
|
|
limitRate(user, Posts, 30);
|
|
|
|
post = _.extend(post, {
|
|
userId: user._id,
|
|
author: user.username,
|
|
submitted: new Date().getTime(),
|
|
votes: 0,
|
|
comments: 0,
|
|
baseScore: 0,
|
|
score: 0
|
|
});
|
|
|
|
var postId=Posts.insert(post);
|
|
|
|
Meteor.call('upvotePost', postId);
|
|
|
|
return postId;
|
|
}
|
|
}); |