feat: add route to fetch user by jellyfin id#2074
feat: add route to fetch user by jellyfin id#2074fredrikburmester wants to merge 4 commits intoseerr-team:developfrom
Conversation
|
You will also need to update the API's documentation to make this work. |
|
Thank you I'll do that. |
|
Added ✅ @0xSysR3ll One question though. The Am I misunderstanding how permissions are handled, or is it fine as I've written it? |
It's fine like you wrote it, the description from the |
|
This PR is stale because it has been open 30 days with no activity. Please address the feedback or provide an update to keep it open. |
|
@fredrikburmester are you able to work on this pr or should we take over? |
|
Sorry i totally forgot about fixing the formatting issue. I can get to it tonight but if you have time, feel free to fix and merge. |
|
This PR is stale because it has been open 30 days with no activity. Please address the feedback or provide an update to keep it open. |
|
This PR was closed because it has been stalled for 30 days with no activity. You can reopen it once you address the feedback or provide the requested changes. |
|
anything missing from this pr to get review ? |
|
#2074 (comment) |
Dismissing till requested changes are resolved
|
This PR is stale because it has been open 30 days with no activity. Please address the feedback or provide an update to keep it open. |
📝 WalkthroughWalkthroughA new API endpoint is added to retrieve a user by their Jellyfin ID via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@server/routes/user/index.ts`:
- Around line 429-431: The DB lookup uses the raw path param
req.params.jellyfinUserId which can cause false 404s for equivalent IDs with
different casing/whitespace/formatting; before calling
userRepository.findOneOrFail, normalize the incoming ID (e.g., trim(),
toLowerCase(), and any Jellyfin-specific canonicalization such as removing
surrounding braces or prefixes) into a variable (e.g., normalizedJellyfinId) and
use that variable in the where clause instead of req.params.jellyfinUserId so
lookups match stored normalized IDs in the User entity.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d20a7055-2406-4e8a-97e0-4cf67771c953
📒 Files selected for processing (2)
seerr-api.ymlserver/routes/user/index.ts
There was a problem hiding this comment.
♻️ Duplicate comments (1)
server/routes/user/index.ts (1)
429-436:⚠️ Potential issue | 🟠 MajorSupport both raw and normalized Jellyfin IDs during lookup.
At Line 434, the query only uses the normalized ID. Because existing records can still contain non-normalized
jellyfinUserIdvalues, this can return false 404s. Query both raw and normalized forms (or backfill normalized IDs) for compatibility.Suggested patch
- const jellyfinUserId = normalizeJellyfinGuid(req.params.jellyfinUserId); + const rawJellyfinUserId = req.params.jellyfinUserId; + const jellyfinUserId = normalizeJellyfinGuid(rawJellyfinUserId); if (!jellyfinUserId) { return next({ status: 400, message: 'Invalid Jellyfin User ID.' }); } const user = await userRepository.findOneOrFail({ - where: { jellyfinUserId }, + where: [ + { jellyfinUserId }, + { jellyfinUserId: rawJellyfinUserId }, + ], });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/routes/user/index.ts` around lines 429 - 436, The lookup uses only the normalized ID (jellyfinUserId) so existing records with raw IDs may be missed; modify the retrieval logic around normalizeJellyfinGuid and userRepository.findOneOrFail to query for either the normalized value or the original req.params.jellyfinUserId (e.g., use a WHERE with OR on jellyfinUserId or two-step lookup: try findOneOrFail by normalized ID then fallback to the raw ID) while keeping normalizeJellyfinGuid, jellyfinUserId, req.params.jellyfinUserId and userRepository.findOneOrFail as the referenced symbols.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@server/routes/user/index.ts`:
- Around line 429-436: The lookup uses only the normalized ID (jellyfinUserId)
so existing records with raw IDs may be missed; modify the retrieval logic
around normalizeJellyfinGuid and userRepository.findOneOrFail to query for
either the normalized value or the original req.params.jellyfinUserId (e.g., use
a WHERE with OR on jellyfinUserId or two-step lookup: try findOneOrFail by
normalized ID then fallback to the raw ID) while keeping normalizeJellyfinGuid,
jellyfinUserId, req.params.jellyfinUserId and userRepository.findOneOrFail as
the referenced symbols.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e0c7df79-eef3-4752-a24a-c29fb50f0e27
📒 Files selected for processing (1)
server/routes/user/index.ts
Description
Fetch a seerr user by Jellyfin ID. Currently this is not possible and from my understanding makes it difficult for clients to find a user without fetching all users and matching the ID.
How Has This Been Tested?
Not tested.
Screenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit
Summary by CodeRabbit