Skip to content
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

Merged
merged 1 commit into from
Nov 13, 2023
Merged

Conversation

cavis
Copy link
Member

@cavis cavis commented Nov 8, 2023

Feeds were not being filtered correctly.

@cavis cavis self-assigned this Nov 8, 2023
# 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)
Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

@cavis cavis merged commit 967b8e7 into main Nov 13, 2023
@cavis cavis deleted the fix/filter_auth_feeds branch November 13, 2023 19:36
Copy link
Member

@kookster kookster left a 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
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants