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

feat(platform): add file upload endpoint #172

Merged
merged 1 commit into from
Dec 31, 2023

Conversation

TroyKomodo
Copy link
Member

Proposed changes

Adds a generic file upload rest endpoint.

The idea is, you will query GQL and the GQL API will return a token you can use to upload a file to. (Something like a singed URL, except its just a token you put into the Authentication Header). We then query (delete) the token in the database to validate that the token has not already been used (deleted). Once we have everything we need, the database will tell us how we need to handle the uploaded file. Right now all we will support is image uploads for Profile pictures, or banners or whatever. But in future we may allow any file upload and it will all use the same endpoint which makes things nice and simple.

Types of changes

What types of changes does your code introduce to Scuffle?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

.-.

Copy link

codecov bot commented Dec 30, 2023

Codecov Report

Attention: 588 lines in your changes are missing coverage. Please review.

Comparison is base (1e25f4b) 53.24% compared to head (58010f5) 52.38%.

❗ Current head 58010f5 differs from pull request most recent head 138cecd. Consider uploading reports for the commit 138cecd to get more accurate results

Additional details and impacted files
@@                 Coverage Diff                 @@
##           feature/website     #172      +/-   ##
===================================================
- Coverage            53.24%   52.38%   -0.87%     
===================================================
  Files                  441      449       +8     
  Lines                26885    27327     +442     
===================================================
  Hits                 14316    14316              
- Misses               12569    13011     +442     
Files Coverage Δ
platform/api/src/api/error.rs 0.00% <ø> (ø)
platform/api/src/api/v1/gql/models/ulid.rs 0.00% <ø> (ø)
platform/api/src/database/user.rs 0.00% <ø> (ø)
platform/image_processor/src/config.rs 0.00% <ø> (ø)
platform/api/src/api/middleware/auth.rs 0.00% <0.00%> (ø)
platform/api/src/api/v1/gql/handlers.rs 0.00% <0.00%> (ø)
platform/api/src/api/v1/gql/mutations/chat.rs 0.00% <0.00%> (ø)
platform/api/src/api/v1/gql/subscription/chat.rs 0.00% <0.00%> (ø)
platform/api/src/api/v1/mod.rs 0.00% <0.00%> (ø)
platform/api/src/database/file_type.rs 0.00% <0.00%> (ø)
... and 20 more

@TroyKomodo TroyKomodo marked this pull request as ready for review December 30, 2023 23:05
@TroyKomodo TroyKomodo requested a review from a team as a code owner December 30, 2023 23:05
@TroyKomodo TroyKomodo changed the title feat: add file upload endpoint feat(platform): add file upload endpoint Dec 30, 2023
Copy link
Member

@lennartkloock lennartkloock left a comment

Choose a reason for hiding this comment

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

lgtm

Adds a profile picture upload endpoint the url is
`PATCH /v1/upload/profile-picture`

This implementation is generic and can support other types of image
uploading too. Simply implement the `UploadType` trait and then add a
new route using the `api::v1::upload::handler` and then everything will
just work.

Added the GQL endpoints to subscribe and get profile pictures from
users.

Refactored event publishing using an enum for subjects.
@TroyKomodo TroyKomodo merged commit 359a5da into feature/website Dec 31, 2023
5 of 7 checks passed
@TroyKomodo TroyKomodo deleted the troy/api-images branch December 31, 2023 01:17
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