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

Add public API endpoint for public collections #2174

Open
wants to merge 18 commits into
base: public-collections-feature
Choose a base branch
from

Conversation

tw4l
Copy link
Member

@tw4l tw4l commented Nov 22, 2024

Fixes #1051

If org with provided slug doesn't exist or no public collections exist for that org, return same 404 response with a detail of "public_profile_not_found" to prevent people from using public endpoint to determine whether an org exists.

Endpoint is GET /api/public-collections/<org-slug> (no auth needed) to avoid collisions with existing org and collection endpoints.

@SuaYoo happy to make any changes needed for the frontend, just lmk!

If org with provided slug doesn't exist or no public collections
exist for that org, return same 404 response with a detail of
"public_collections_not_found" to prevent people from using public
endpoint to determine whether an org exists.

Endpoint is /api/public-collections/<org-slug> to avoid collisions
with existing org and collection endpoints.
@tw4l tw4l requested a review from SuaYoo November 22, 2024 21:54
backend/btrixcloud/colls.py Show resolved Hide resolved
backend/btrixcloud/colls.py Show resolved Hide resolved
This will be more easily extensible if we want to add additional
fields (like an organization description) that would be visible in
a public profile.
@tw4l tw4l marked this pull request as draft November 25, 2024 20:40
@tw4l
Copy link
Member Author

tw4l commented Nov 25, 2024

Converting to draft while I make changes

@tw4l tw4l marked this pull request as ready for review November 25, 2024 21:54
@tw4l tw4l requested review from SuaYoo and ikreymer November 25, 2024 21:54
@tw4l
Copy link
Member Author

tw4l commented Nov 25, 2024

Made all of the changes except the 404 -> 200 change. Also restructured the response a bit to look like:

{
  "org": {
    "name": "Org name",
    // Can easily add other fields here moving forward
  },
  "collections": [
    {"id": "some uuid", "name": "A public collection", "access": "public",...},
    ...
  ]
}

@tw4l
Copy link
Member Author

tw4l commented Nov 25, 2024

Also tagged @ikreymer to see if he has thoughts/comments/suggested changes (overall and/or on the 404 question)

@tw4l
Copy link
Member Author

tw4l commented Nov 26, 2024

Added support for a public org description (editing via same /public-profile endpoint that's used to enable/disable public profile), as requested in #1051 (comment)

@SuaYoo SuaYoo self-requested a review November 26, 2024 19:25
@tw4l
Copy link
Member Author

tw4l commented Nov 26, 2024

Some additional changes made:

  • Public profiles can now include a URL field
  • /public-collections endpoint still returns data if org has public profile enabled even if there are no public collections yet
  • 404 message for /public-collections endpoint modified to public_profile_not_found

Copy link
Member

@SuaYoo SuaYoo left a comment

Choose a reason for hiding this comment

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

Looks good! Tested with #2172

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.

2 participants