From 2c6d347b80dcdb7ebebd72567598fca76f2b6029 Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Tue, 20 Aug 2013 15:18:50 -0600 Subject: [PATCH] Link hiding: don't hide own posts due to low score Also refactored logic of this section to be a lot simpler. --- r2/r2/models/link.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index 5029aacfa..2e88b6646 100755 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -243,29 +243,18 @@ class Link(Thing, Printable): #return False if user and not c.ignore_hide_rules: - # whether the user must deliberately hide the item - # (not automatic due to score or having upvoted/downvoted it) - require_explicit_hide = wrapped.stickied - - if (user.pref_hide_ups and - wrapped.likes == True and - self.author_id != user._id and - not require_explicit_hide): - return False - - if (user.pref_hide_downs and - wrapped.likes == False and - self.author_id != user._id and - not require_explicit_hide): - return False - - if (wrapped._score < user.pref_min_link_score and - not require_explicit_hide): - return False - if wrapped.hidden: return False + # never automatically hide user's own posts or stickies + allow_auto_hide = (not wrapped.stickied and + self.author_id != user._id) + if (allow_auto_hide and + ((user.pref_hide_ups and wrapped.likes == True) or + (user.pref_hide_downs and wrapped.likes == False) or + wrapped._score < user.pref_min_link_score)): + return False + # Always show NSFW to API users unless obey_over18=true in querystring is_api = c.render_style in extensions.API_TYPES if is_api and not c.obey_over18: