[PR #23425] [CLOSED] fix(server): improve user agent detection for Immich app #17529

Closed
opened 2026-02-05 16:23:27 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/23425
Author: @aviv926
Created: 10/31/2025
Status: Closed

Base: mainHead: fix-device-card


📝 Commits (5)

  • 8890bbf fix(server): improve user agent detection for Immich app
  • 664dd63 add fix for deviceOS and deviceType
  • 20916bd make sql
  • 76526db add deviceOS and deviceType to session mock data
  • f2cc06c optimize session update logic for appVersion, deviceOS, and deviceType

📊 Changes

6 files changed (+51 additions, -11 deletions)

View changed files

📝 server/src/database.ts (+8 -1)
📝 server/src/queries/session.repository.sql (+2 -0)
📝 server/src/services/auth.service.spec.ts (+8 -0)
📝 server/src/services/auth.service.ts (+14 -6)
📝 server/src/utils/request.ts (+17 -1)
📝 web/src/lib/components/user-settings-page/device-card.svelte (+2 -3)

📄 Description

This PR addresses several issues with the new option added in #21345:

  1. Sometimes the app doesn't send a UA with a version number but only another UA like

^Mobile$/, /^Dart//, /^immich_mobile/, /^AppleCoreMedia/, /^Dalvik/

From now on we keep the last version number received until a new one is received with the UA

  1. Because the app's UA is inconsistent it could sometimes appear as mobile without the app version (due to issue .1 I mentioned) and sometimes as "unknown", to solve this I perform a test using isImmichApp to check if it is an immich app sending the UA or not.
    The test is robust enough because it checks 2 things

  2. Is a version number included in the UA?

  3. Does it contain other UAs sent by the app but not containing the original UA we expect?

If so, it will be considered an Immich app in the UI along with the version number.


🔄 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/immich-app/immich/pull/23425 **Author:** [@aviv926](https://github.com/aviv926) **Created:** 10/31/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-device-card` --- ### 📝 Commits (5) - [`8890bbf`](https://github.com/immich-app/immich/commit/8890bbf5da851b216543c6e3e4df4daeeba2fc7e) fix(server): improve user agent detection for Immich app - [`664dd63`](https://github.com/immich-app/immich/commit/664dd6332582cfe7d1801aaab28f593eaaedc2b5) add fix for deviceOS and deviceType - [`20916bd`](https://github.com/immich-app/immich/commit/20916bdbb5ab5adf7e27a7dd32b8d679ffee09aa) make sql - [`76526db`](https://github.com/immich-app/immich/commit/76526db854f4c57000688b5c9491133b9ddb09c3) add deviceOS and deviceType to session mock data - [`f2cc06c`](https://github.com/immich-app/immich/commit/f2cc06c04e59df29d2a470fb77241d7693b17466) optimize session update logic for appVersion, deviceOS, and deviceType ### 📊 Changes **6 files changed** (+51 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `server/src/database.ts` (+8 -1) 📝 `server/src/queries/session.repository.sql` (+2 -0) 📝 `server/src/services/auth.service.spec.ts` (+8 -0) 📝 `server/src/services/auth.service.ts` (+14 -6) 📝 `server/src/utils/request.ts` (+17 -1) 📝 `web/src/lib/components/user-settings-page/device-card.svelte` (+2 -3) </details> ### 📄 Description This PR addresses several issues with the new option added in #21345: 1. Sometimes the app doesn't send a UA with a version number but only another UA like ^Mobile$/, /^Dart\//, /^immich_mobile/, /^AppleCoreMedia/, /^Dalvik\/ From now on we keep the last version number received until a new one is received with the UA 2. Because the app's UA is inconsistent it could sometimes appear as mobile without the app version (due to issue .1 I mentioned) and sometimes as "unknown", to solve this I perform a test using isImmichApp to check if it is an immich app sending the UA or not. The test is robust enough because it checks 2 things 1. Is a version number included in the UA? 2. Does it contain other UAs sent by the app but not containing the original UA we expect? If so, it will be considered an Immich app in the UI along with the version number. --- <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 2026-02-05 16:23:27 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#17529