Skip to content

Commit 15296a0

Browse files
feat: add route to fetch user by jellyfin id (#2074)
Co-authored-by: gauthier-th <mail@gauthierth.fr>
1 parent 217fcef commit 15296a0

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

seerr-api.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4449,6 +4449,29 @@ paths:
44494449
application/json:
44504450
schema:
44514451
$ref: '#/components/schemas/User'
4452+
/user/jellyfin/{jellyfinUserId}:
4453+
get:
4454+
summary: Get user by Jellyfin user ID
4455+
description: |
4456+
Retrieves user details by Jellyfin user ID in a JSON object. Returns filtered data based on the caller's permissions.
4457+
tags:
4458+
- users
4459+
parameters:
4460+
- in: path
4461+
name: jellyfinUserId
4462+
required: true
4463+
schema:
4464+
type: string
4465+
description: The Jellyfin user ID (32-character hexadecimal string)
4466+
responses:
4467+
'200':
4468+
description: User details in JSON
4469+
content:
4470+
application/json:
4471+
schema:
4472+
$ref: '#/components/schemas/User'
4473+
'404':
4474+
description: User not found
44524475
/user/{userId}/requests:
44534476
get:
44544477
summary: Get requests for a specific user

server/routes/user/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,30 @@ router.get<{ id: string }>('/:id', async (req, res, next) => {
420420
}
421421
});
422422

423+
router.get<{ jellyfinUserId: string }>(
424+
'/jellyfin/:jellyfinUserId',
425+
async (req, res, next) => {
426+
try {
427+
const userRepository = getRepository(User);
428+
429+
const jellyfinUserId = normalizeJellyfinGuid(req.params.jellyfinUserId);
430+
if (!jellyfinUserId) {
431+
return next({ status: 400, message: 'Invalid Jellyfin User ID.' });
432+
}
433+
434+
const user = await userRepository.findOneOrFail({
435+
where: { jellyfinUserId },
436+
});
437+
438+
return res
439+
.status(200)
440+
.json(user.filter(req.user?.hasPermission(Permission.MANAGE_USERS)));
441+
} catch {
442+
next({ status: 404, message: 'User not found.' });
443+
}
444+
}
445+
);
446+
423447
router.use('/:id/settings', userSettingsRoutes);
424448

425449
router.get<{ id: string }, UserRequestsResponse>(

0 commit comments

Comments
 (0)