-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter auth feeds by authorized podcasts #909
Conversation
# avoid joining podcasts here, as it breaks a bunch of other queries | ||
def token_auth_episodes | ||
if token.globally_authorized?("read-private") | ||
Episode.with_deleted.all | ||
else | ||
Episode.where(podcast_id: token_auth_podcasts.pluck(:id)) | ||
Episode.where("podcast_id IN (SELECT id FROM podcasts WHERE prx_account_uri IN (?))", token_auth_account_uris) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely related - but it's slightly faster to do a subquery here, rather than 2 separate queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had a question about "deleted" feeds?
@@ -1,4 +1,6 @@ | |||
class Api::Auth::FeedsController < Api::BaseController | |||
include ApiAuthenticated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, exactly
@@ -40,12 +40,20 @@ def token_auth_podcasts | |||
end | |||
end | |||
|
|||
def token_auth_feeds | |||
if token.globally_authorized?("read-private") | |||
Feed.with_deleted.all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted? we're returning deleted feeds? I am confused by this....
# avoid joining podcasts here, as it breaks a bunch of other queries | ||
def token_auth_episodes | ||
if token.globally_authorized?("read-private") | ||
Episode.with_deleted.all | ||
else | ||
Episode.where(podcast_id: token_auth_podcasts.pluck(:id)) | ||
Episode.where("podcast_id IN (SELECT id FROM podcasts WHERE prx_account_uri IN (?))", token_auth_account_uris) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure!
Feeds were not being filtered correctly.