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

refactor: Proxy and cache avatar images #907

Merged
merged 16 commits into from
Sep 19, 2024

Conversation

JoaquinOlivero
Copy link
Contributor

Description

This PR changes how Jellyseerr handles profile images. Now they are proxied from the source and cached in the disk.
The caching mechanism uses the already existing "ImageProxy" class which I tweaked.

Also, I added a new endpoint "/avatarproxy" that takes the URL from the images, caches them if needed, and then returns them.

Screenshot (if UI-related)

To-Dos

  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Issues Fixed or Closed

  • Fixes #XXXX

server/lib/imageproxy.ts Fixed Show fixed Hide fixed
Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

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

Well done!

server/lib/imageproxy.ts Outdated Show resolved Hide resolved
server/lib/imageproxy.ts Outdated Show resolved Hide resolved
src/components/UserProfile/ProfileHeader/index.tsx Outdated Show resolved Hide resolved
server/lib/imageproxy.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot added the merge conflict Cannot merge due to merge conflicts label Aug 11, 2024
Copy link

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@gauthier-th gauthier-th mentioned this pull request Aug 12, 2024
15 tasks
@github-actions github-actions bot removed the merge conflict Cannot merge due to merge conflicts label Aug 13, 2024
gauthier-th
gauthier-th previously approved these changes Aug 16, 2024
@Gauvino
Copy link
Contributor

Gauvino commented Aug 17, 2024

No problem at all work's great !

src/i18n/locale/en.json Outdated Show resolved Hide resolved
gauthier-th
gauthier-th previously approved these changes Aug 20, 2024
@github-actions github-actions bot added the merge conflict Cannot merge due to merge conflicts label Aug 20, 2024
Copy link

This pull request has merge conflicts. Please resolve the conflicts so the PR can be successfully reviewed and merged.

@fallenbagel
Copy link
Owner

fallenbagel commented Aug 21, 2024

@JoaquinOlivero could you resolve the conflicts? So we can get this in

EDIT: its okay I have done it c:

@github-actions github-actions bot removed the merge conflict Cannot merge due to merge conflicts label Aug 22, 2024
server/routes/auth.ts Fixed Show fixed Hide fixed
server/routes/auth.ts Fixed Show fixed Hide fixed
server/routes/auth.ts Fixed Show fixed Hide fixed
server/routes/auth.ts Fixed Show fixed Hide fixed
server/routes/avatarproxy.ts Fixed Show fixed Hide fixed
server/routes/user/index.ts Fixed Show fixed Hide fixed
server/routes/user/index.ts Fixed Show fixed Hide fixed
server/routes/auth.ts Fixed Show fixed Hide fixed
server/routes/auth.ts Fixed Show fixed Hide fixed
server/routes/auth.ts Fixed Show fixed Hide fixed
server/routes/auth.ts Fixed Show fixed Hide fixed
server/routes/avatarproxy.ts Fixed Show fixed Hide fixed
server/routes/user/index.ts Fixed Show fixed Hide fixed
server/routes/user/index.ts Fixed Show fixed Hide fixed
Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

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

Could you try to replace .startsWith('https://gravatar.com') with .startsWith('https://gravatar.com/') (note the / at the end) to see if it fixes the GitHub security warnings?

src/components/Common/CachedImage/index.tsx Outdated Show resolved Hide resolved
src/components/Common/CachedImage/index.tsx Outdated Show resolved Hide resolved
gauthier-th
gauthier-th previously approved these changes Sep 10, 2024
Copy link
Collaborator

@gauthier-th gauthier-th left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Owner

@fallenbagel fallenbagel left a comment

Choose a reason for hiding this comment

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

Have not tested yet but LGTM

@gauthier-th gauthier-th added the preview PRs deployed for testing with tag `:preview-prxx` label Sep 16, 2024
Copy link
Owner

@fallenbagel fallenbagel left a comment

Choose a reason for hiding this comment

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

Some issues were reported (on issues index) in discord so until that is fixed

package.json Show resolved Hide resolved
Copy link
Owner

@fallenbagel fallenbagel left a comment

Choose a reason for hiding this comment

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

Everything looks good!

@fallenbagel fallenbagel merged commit edfd804 into fallenbagel:develop Sep 19, 2024
9 checks passed
@fallenbagel
Copy link
Owner

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

bonswouar pushed a commit to bonswouar/jellyseerr that referenced this pull request Nov 10, 2024
* refactor: proxy and cache user avatar images

* fix: extract keys

* fix: set avatar image URL

* fix: show the correct avatar in the list of available users in advanced request

* fix(s): set correct src URL for cached image

* fix: remove unexpired unused image when a user changes their avatar

* fix: requested changes

* refactor: use 'mime' package to detmerine file extension

* style: grammar

* refactor: checks if the default avatar is cached to avoid creating duplicates for different users

* fix: fix vulnerability

* fix: fix incomplete URL substring sanitization

* refactor: only cache avatar with http url protocol

* fix: remove log and correctly set the if statement for the cached image component

* fix: avatar images not showing on issues page

* style: formatting

---------

Co-authored-by: JoaquinOlivero <[email protected]>
thibodelanghe pushed a commit to thibodelanghe/jellyseerr that referenced this pull request Dec 18, 2024
* refactor: proxy and cache user avatar images

* fix: extract keys

* fix: set avatar image URL

* fix: show the correct avatar in the list of available users in advanced request

* fix(s): set correct src URL for cached image

* fix: remove unexpired unused image when a user changes their avatar

* fix: requested changes

* refactor: use 'mime' package to detmerine file extension

* style: grammar

* refactor: checks if the default avatar is cached to avoid creating duplicates for different users

* fix: fix vulnerability

* fix: fix incomplete URL substring sanitization

* refactor: only cache avatar with http url protocol

* fix: remove log and correctly set the if statement for the cached image component

* fix: avatar images not showing on issues page

* style: formatting

---------

Co-authored-by: JoaquinOlivero <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview PRs deployed for testing with tag `:preview-prxx` released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants