mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 15:58:06 -05:00
Don't show very young links on the new page, so that the thumbnail fetcher et al have had time to act on them
This commit is contained in:
@@ -125,6 +125,7 @@ HOT_PAGE_AGE = 1
|
||||
#
|
||||
media_period = 10 minutes
|
||||
rising_period = 12 hours
|
||||
new_incubation = 90 seconds
|
||||
|
||||
# time of ratelimit purgatory (min)
|
||||
RATELIMIT = 10
|
||||
|
||||
@@ -34,7 +34,7 @@ from r2.lib.db import queries
|
||||
from r2.lib.strings import Score
|
||||
from r2.lib import organic
|
||||
from r2.lib.solrsearch import SearchQuery
|
||||
from r2.lib.utils import iters, check_cheating
|
||||
from r2.lib.utils import iters, check_cheating, timeago
|
||||
from r2.lib import sup
|
||||
|
||||
from admin import admin_profile_query
|
||||
@@ -127,10 +127,14 @@ class ListingController(RedditController):
|
||||
after = self.after,
|
||||
count = self.count,
|
||||
reverse = self.reverse,
|
||||
keep_fn = self.keep_fn(),
|
||||
wrap = self.builder_wrapper)
|
||||
|
||||
return b
|
||||
|
||||
def keep_fn(self):
|
||||
return None
|
||||
|
||||
def listing(self):
|
||||
"""Listing to generate from the builder"""
|
||||
listing = LinkListing(self.builder_obj, show_nums = self.show_nums)
|
||||
@@ -279,12 +283,34 @@ class NewController(ListingController):
|
||||
def menus(self):
|
||||
return [NewMenu(default = self.sort)]
|
||||
|
||||
def keep_fn(self):
|
||||
def keep(item):
|
||||
"""Avoid showing links that are too young, to give time
|
||||
for things like the spam filter and thumbnail fetcher to
|
||||
act on them before releasing them into the wild"""
|
||||
wouldkeep = item.keep_item(item)
|
||||
if c.user_is_loggedin and (c.user_is_admin or item.subreddit.is_moderator(c.user)):
|
||||
# let admins and moderators see them regardless
|
||||
return wouldkeep
|
||||
elif wouldkeep and c.user_is_loggedin and c.user._id == item.author_id:
|
||||
# also let the author of the link see them
|
||||
return True
|
||||
elif item._date > timeago(g.new_incubation):
|
||||
# it's too young to show yet
|
||||
return False
|
||||
else:
|
||||
# otherwise, fall back to the regular logic (don't
|
||||
# show hidden links, etc)
|
||||
return wouldkeep
|
||||
|
||||
return keep
|
||||
|
||||
def query(self):
|
||||
if self.sort == 'rising':
|
||||
return get_rising(c.site)
|
||||
else:
|
||||
return c.site.get_links('new', 'all')
|
||||
|
||||
|
||||
@validate(sort = VMenu('controller', NewMenu))
|
||||
def GET_listing(self, sort, **env):
|
||||
self.sort = sort
|
||||
|
||||
Reference in New Issue
Block a user