[PR #965] [MERGED] fix: decouple images from app config service #524

Closed
opened 2025-10-07 00:17:56 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/pocket-id/pocket-id/pull/965
Author: @stonith404
Created: 9/19/2025
Status: Merged
Merged: 9/20/2025
Merged by: @stonith404

Base: mainHead: refactor/application-images


📝 Commits (6)

  • 5c29b27 refactor: decouple images from app config service
  • d11b6d9 fix linter issues
  • d537a5c fix api paths
  • 6f6a744 Update backend/internal/utils/file_util.go
  • 981ec24 use filepath instead of path
  • d33298d Merge branch 'main' into refactor/application-images

📊 Changes

19 files changed (+426 additions, -314 deletions)

View changed files

📝 backend/internal/bootstrap/app_images_bootstrap.go (+19 -41)
backend/internal/bootstrap/application_images_bootstrap_test.go (+0 -61)
📝 backend/internal/bootstrap/bootstrap.go (+2 -2)
📝 backend/internal/bootstrap/router_bootstrap.go (+4 -3)
📝 backend/internal/bootstrap/services_bootstrap.go (+4 -1)
📝 backend/internal/controller/app_config_controller.go (+0 -150)
backend/internal/controller/app_images_controller.go (+173 -0)
📝 backend/internal/model/app_config.go (+1 -4)
📝 backend/internal/service/app_config_service.go (+1 -38)
backend/internal/service/app_images_service.go (+82 -0)
backend/internal/service/app_images_service_test.go (+88 -0)
📝 backend/internal/service/email_service.go (+1 -1)
📝 backend/internal/utils/file_util.go (+10 -0)
📝 backend/internal/utils/file_util_test.go (+28 -0)
📝 frontend/src/app.html (+1 -1)
📝 frontend/src/lib/services/app-config-service.ts (+3 -3)
📝 frontend/src/lib/utils/cached-image-util.ts (+4 -4)
📝 frontend/src/routes/settings/admin/application-configuration/update-application-images.svelte (+1 -1)
📝 tests/specs/application-configuration.spec.ts (+4 -4)

📄 Description

This PR separates the handling of application images (such as the logo and background) from the AppConfigService. By decoupling this logic, the codebase becomes cleaner and avoids bugs caused by inconsistencies in file type management.

Currently, Pocket ID stores the file extension of uploaded images in the database at the time of upload. If a user later replaces images directly on the filesystem, the stored extension can fall out of sync with the actual file, preventing the image from being displayed. A similar issue occurred in #964, where users had uploaded a custom JPG image. Since the last release changed the default background image format in AppConfigService from JPG to WEBP, Pocket ID incorrectly assumed those users were using a WEBP file instead of their actual JPG, which led to display problems.


Closes #964


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/pocket-id/pocket-id/pull/965 **Author:** [@stonith404](https://github.com/stonith404) **Created:** 9/19/2025 **Status:** ✅ Merged **Merged:** 9/20/2025 **Merged by:** [@stonith404](https://github.com/stonith404) **Base:** `main` ← **Head:** `refactor/application-images` --- ### 📝 Commits (6) - [`5c29b27`](https://github.com/pocket-id/pocket-id/commit/5c29b272380181f0c0758ed12ad1ffd4dc6da6fb) refactor: decouple images from app config service - [`d11b6d9`](https://github.com/pocket-id/pocket-id/commit/d11b6d94a42771b4444308b9860a821942c55d8c) fix linter issues - [`d537a5c`](https://github.com/pocket-id/pocket-id/commit/d537a5cb74440a025cdb4e4c5efdd8100bdf8a40) fix api paths - [`6f6a744`](https://github.com/pocket-id/pocket-id/commit/6f6a7443ce4a276e511c864a68ed989f57dccf2e) Update backend/internal/utils/file_util.go - [`981ec24`](https://github.com/pocket-id/pocket-id/commit/981ec241c9f4305ded8186a7fb8d25efe4e47493) use filepath instead of path - [`d33298d`](https://github.com/pocket-id/pocket-id/commit/d33298d28d0ec4a02a1cffcea4a57e1ca794b24d) Merge branch 'main' into refactor/application-images ### 📊 Changes **19 files changed** (+426 additions, -314 deletions) <details> <summary>View changed files</summary> 📝 `backend/internal/bootstrap/app_images_bootstrap.go` (+19 -41) ➖ `backend/internal/bootstrap/application_images_bootstrap_test.go` (+0 -61) 📝 `backend/internal/bootstrap/bootstrap.go` (+2 -2) 📝 `backend/internal/bootstrap/router_bootstrap.go` (+4 -3) 📝 `backend/internal/bootstrap/services_bootstrap.go` (+4 -1) 📝 `backend/internal/controller/app_config_controller.go` (+0 -150) ➕ `backend/internal/controller/app_images_controller.go` (+173 -0) 📝 `backend/internal/model/app_config.go` (+1 -4) 📝 `backend/internal/service/app_config_service.go` (+1 -38) ➕ `backend/internal/service/app_images_service.go` (+82 -0) ➕ `backend/internal/service/app_images_service_test.go` (+88 -0) 📝 `backend/internal/service/email_service.go` (+1 -1) 📝 `backend/internal/utils/file_util.go` (+10 -0) 📝 `backend/internal/utils/file_util_test.go` (+28 -0) 📝 `frontend/src/app.html` (+1 -1) 📝 `frontend/src/lib/services/app-config-service.ts` (+3 -3) 📝 `frontend/src/lib/utils/cached-image-util.ts` (+4 -4) 📝 `frontend/src/routes/settings/admin/application-configuration/update-application-images.svelte` (+1 -1) 📝 `tests/specs/application-configuration.spec.ts` (+4 -4) </details> ### 📄 Description This PR separates the handling of application images (such as the logo and background) from the `AppConfigService`. By decoupling this logic, the codebase becomes cleaner and avoids bugs caused by inconsistencies in file type management. Currently, Pocket ID stores the file extension of uploaded images in the database at the time of upload. If a user later replaces images directly on the filesystem, the stored extension can fall out of sync with the actual file, preventing the image from being displayed. A similar issue occurred in #964, where users had uploaded a custom JPG image. Since the last release changed the default background image format in `AppConfigService` from JPG to WEBP, Pocket ID incorrectly assumed those users were using a WEBP file instead of their actual JPG, which led to display problems. --- Closes #964 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2025-10-07 00:17:56 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id#524