Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Api: Add another 'where' to user/where end point
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisst committed Apr 1, 2015
1 parent 86ae369 commit 22625ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions r2/r2/controllers/listingcontroller.py
Expand Up @@ -822,6 +822,13 @@ def query(self):
sr_id = self.savedsr._id if self.savedsr else None
q = queries.get_saved(self.vuser, sr_id,
category=self.savedcategory)
elif self.where == 'actions':
self.check_modified(self.vuser, 'actions')
if not votes_visible(self.vuser):
q = queries.get_overview(self.vuser, self.sort, self.time)
else:
q = queries.get_user_actions(self.vuser, 'new', 'all')

elif c.user_is_sponsor and self.where == 'promoted':
q = queries.get_promoted_links(self.vuser._id)

Expand Down Expand Up @@ -857,10 +864,9 @@ def GET_listing(self, where, vuser, sort, time, show, **env):
if c.user_is_admin:
c.referrer_policy = "always"

if self.sort in ('hot', 'new'):
if self.sort in ('hot', 'new'):
self.time = 'all'


# hide spammers profile pages
if vuser._spam and not vuser.banned_profile_visible:
if (not c.user_is_loggedin or
Expand All @@ -872,7 +878,7 @@ def GET_listing(self, where, vuser, sort, time, show, **env):
if where in ('liked', 'disliked') and not votes_visible(vuser):
return self.abort403()

if ((where in ('saved', 'hidden') or
if ((where in ('saved', 'hidden') or
(where == 'gilded' and show == 'given')) and
not (c.user_is_loggedin and c.user._id == vuser._id) and
not c.user_is_admin):
Expand Down
5 changes: 5 additions & 0 deletions r2/r2/lib/db/queries.py
Expand Up @@ -528,6 +528,11 @@ def _get_submitted(user_id, sort, time):
def get_submitted(user, sort, time):
return _get_submitted(user._id, sort, time)

def get_user_actions(user, sort, time):
return merge_results(get_comments(user, sort, time),
get_submitted(user, sort, time),
get_liked(user))

def get_overview(user, sort, time):
return merge_results(get_comments(user, sort, time),
get_submitted(user, sort, time))
Expand Down

0 comments on commit 22625ac

Please sign in to comment.