mirror of
https://github.com/vale981/Vulcan
synced 2025-03-08 19:11:38 -05:00
limit same url check to past 6 months
This commit is contained in:
parent
07b84b608f
commit
3209e91aca
1 changed files with 10 additions and 5 deletions
|
@ -117,7 +117,6 @@ Meteor.methods({
|
|||
user = Meteor.user(),
|
||||
userId = user._id,
|
||||
submitted = post.submitted || new Date(),
|
||||
postWithSameLink = Posts.findOne({url: post.url}), // TODO: limit scope of search to past month or something
|
||||
timeSinceLastPost=timeSinceLast(user, Posts),
|
||||
numberOfPostsInPast24Hours=numberOfItemsInPast24Hours(user, Posts),
|
||||
postInterval = Math.abs(parseInt(getSetting('postInterval', 30))),
|
||||
|
@ -135,10 +134,16 @@ Meteor.methods({
|
|||
if(!post.title)
|
||||
throw new Meteor.Error(602, i18n.t('Please fill in a title'));
|
||||
|
||||
// check that there are no previous posts with the same link
|
||||
if(post.url && (typeof postWithSameLink !== 'undefined')){
|
||||
Meteor.call('upvotePost', postWithSameLink);
|
||||
throw new Meteor.Error(603, i18n.t('This link has already been posted'), postWithSameLink._id);
|
||||
|
||||
if(!!post.url){
|
||||
// check that there are no previous posts with the same link in the past 6 months
|
||||
var sixMonthsAgo = moment().subtract('months', 6).toDate();
|
||||
var postWithSameLink = Posts.findOne({url: post.url, postedAt: {$gte: sixMonthsAgo}});
|
||||
|
||||
if(typeof postWithSameLink !== 'undefined'){
|
||||
Meteor.call('upvotePost', postWithSameLink);
|
||||
throw new Meteor.Error(603, i18n.t('This link has already been posted'), postWithSameLink._id);
|
||||
}
|
||||
}
|
||||
|
||||
if(!isAdmin(Meteor.user())){
|
||||
|
|
Loading…
Add table
Reference in a new issue