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 the /api/private/crate-owner-invitations endpoint #3763

Merged
merged 5 commits into from
Aug 18, 2021

Conversation

pietroalbini
Copy link
Member

The endpoint provides a listing of all the invitations sent to the current user or all the invitations to a crate the user owns. Unauthenticated users or unrelated users won't be able to see others' invitations to prevent abuses.

The two ways to query the endpoint are:

GET /api/private/crate-owner-invitations?crate_name={name}
GET /api/private/crate-owner-invitations?invitee_id={uid}

The endpoint is paginated using only seek-based pagination, and the next page field is provided when more results are available.

Once the frontend switches to use the new endpoint we can remove safely remove the old "v1" endpoint, as that's only used for the frontend. Because of this, the "v1" endpoint internally uses the same logic as the new one and converts the data to the old schema.

Part of #2868
r? @Turbo87

@Turbo87 Turbo87 added A-backend ⚙️ C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works labels Jun 29, 2021
@pietroalbini pietroalbini force-pushed the get-crate-owner-invitations branch from a69aa9f to 27bcaf3 Compare June 29, 2021 10:27
@bjorn3
Copy link
Member

bjorn3 commented Jun 29, 2021

The two ways to query the endpoint are:

GET /api/private/crate-owner-invitations?crate_name={name}
GET /api/private/crate-owner-invitations?invitee_id={uid}

So there is no way to list all outstanding invitations you created? Only for specific crates or invitees?

@pietroalbini
Copy link
Member Author

Not in the current implementation. This API is going to be used only by the crates.io frontend, and I'm not aware of plans to display all the invitations sent by the current user. Adding a new list filter is trivial though, and if @Turbo87 wants to implement showing all the invitations sent by the current user in the frontend I'm happy to add the extra filter.

@Turbo87 Turbo87 force-pushed the get-crate-owner-invitations branch from 27bcaf3 to cdd06d6 Compare July 1, 2021 14:02
@Turbo87
Copy link
Member

Turbo87 commented Aug 18, 2021

sorry, forgot that this was still waiting on me 😞

looks great though, so: @bors r+

@bors
Copy link
Contributor

bors commented Aug 18, 2021

📌 Commit cdd06d6 has been approved by Turbo87

@bors
Copy link
Contributor

bors commented Aug 18, 2021

⌛ Testing commit cdd06d6 with merge 58ff83f...

bors added a commit that referenced this pull request Aug 18, 2021
…bo87

Add the `/api/private/crate-owner-invitations` endpoint

The endpoint provides a listing of all the invitations sent to the current user or all the invitations to a crate the user owns. Unauthenticated users or unrelated users won't be able to see others' invitations to prevent abuses.

The two ways to query the endpoint are:

    GET /api/private/crate-owner-invitations?crate_name={name}
    GET /api/private/crate-owner-invitations?invitee_id={uid}

The endpoint is paginated using only seek-based pagination, and the next page field is provided when more results are available.

Once the frontend switches to use the new endpoint we can remove safely remove the old "v1" endpoint, as that's only used for the frontend. Because of this, the "v1" endpoint internally uses the same logic as the new one and converts the data to the old schema.

Part of #2868
r? `@Turbo87`
@bors
Copy link
Contributor

bors commented Aug 18, 2021

💔 Test failed - checks-actions

The endpoint provides a listing of all the invitations sent to the
current user or all the invitations to a crate the user owns.
Unauthenticated users or unrelated users won't be able to see others'
invitations to prevent abuses.

The two ways to query the endpoint are:

    GET /api/private/crate-owner-invitations?crate_name={name}
    GET /api/private/crate-owner-invitations?invitee_id={uid}

The endpoint is paginated using only seek-based pagination, and the
next page field is provided when more results are available.

Once the frontend switches to use the new endpoint we can remove safely
remove the old "v1" endpoint, as that's only used for the frontend.
Because of this, the "v1" endpoint internally uses the same logic as the
new one and converts the data to the old schema.
@Turbo87 Turbo87 force-pushed the get-crate-owner-invitations branch from cdd06d6 to 2d1ac26 Compare August 18, 2021 08:19
@Turbo87
Copy link
Member

Turbo87 commented Aug 18, 2021

rebased to get rid of the merge failure :)

@Turbo87
Copy link
Member

Turbo87 commented Aug 18, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Aug 18, 2021

📌 Commit 2d1ac26 has been approved by Turbo87

@bors
Copy link
Contributor

bors commented Aug 18, 2021

⌛ Testing commit 2d1ac26 with merge 0aadc73...

@bors
Copy link
Contributor

bors commented Aug 18, 2021

☀️ Test successful - checks-actions
Approved by: Turbo87
Pushing 0aadc73 to master...

@bors bors merged commit 0aadc73 into rust-lang:master Aug 18, 2021
@@ -127,6 +127,12 @@ pub fn build_router(app: &App) -> RouteBuilder {
// Metrics
router.get("/api/private/metrics/:kind", C(metrics::prometheus));

// Crate ownership invitations management in the frontend
router.get(
"/api/private/crate-owner-invitations",
Copy link
Member

Choose a reason for hiding this comment

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

hmm, probably should've noticed this earlier: we've been using snake_case for all the URLs so far, instead of kebab-case

Copy link
Member Author

Choose a reason for hiding this comment

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

Ugh, could you send a PR renaming the endpoints?

Copy link
Member

Choose a reason for hiding this comment

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

yep, will do :)

@pietroalbini pietroalbini deleted the get-crate-owner-invitations branch August 19, 2021 17:15
bors added a commit that referenced this pull request Aug 22, 2021
Rename `GET /api/private/crate-owner-invitations` to `GET /api/private/crate_owner_invitations`

... because the rest of the API also uses underscores

Addresses #3763 (comment) :)
bors added a commit that referenced this pull request Aug 29, 2021
mirage/crate-owner-invitation: Adjust fake API to match the real API

#3763 changed a few minor things about the crate owner invitations responses. This PR adjusts our mirage code to match these changes (excluding pagination).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants