Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions seerr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4413,18 +4413,23 @@ paths:
type: string
responses:
'201':
description: A list of the newly created users
description: The newly created users and a count of existing users that were refreshed
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
type: object
properties:
createdUsers:
type: array
items:
$ref: '#/components/schemas/User'
refreshedUsers:
type: number
/user/import-from-jellyfin:
post:
summary: Import all users from Jellyfin
description: |
Fetches and imports users from the Jellyfin server.
Fetches and imports users from the Jellyfin/Emby server. If a list of Jellyfin user IDs is provided in the request body, only the specified users will be created as new accounts. Otherwise, all users will be imported.

Requires the `MANAGE_USERS` permission.
tags:
Expand All @@ -4442,13 +4447,18 @@ paths:
type: string
responses:
'201':
description: A list of the newly created users
description: The newly created users and a count of existing users that were refreshed
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
type: object
properties:
createdUsers:
type: array
items:
$ref: '#/components/schemas/User'
refreshedUsers:
type: number
/user/registerPushSubscription:
post:
summary: Register a web push /user/registerPushSubscription
Expand Down
2 changes: 1 addition & 1 deletion server/routes/avatarproxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function checkAvatarChanged(

let headResponse;
try {
headResponse = await axios.head(jellyfinAvatarUrl);
headResponse = await axios.head(jellyfinAvatarUrl, { timeout: 5000 });
if (headResponse.status !== 200) {
return { changed: false };
}
Expand Down
38 changes: 31 additions & 7 deletions server/routes/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { appDataPath } from '@server/utils/appDataVolume';
import { getAppVersion } from '@server/utils/appVersion';
import { dnsCache } from '@server/utils/dnsCache';
import { getHostname } from '@server/utils/getHostname';
import { normalizeJellyfinGuid } from '@server/utils/jellyfin';
import type { DnsEntries, DnsStats } from 'dns-caching';
import { Router } from 'express';
import rateLimit from 'express-rate-limit';
Expand Down Expand Up @@ -472,14 +473,37 @@ settingsRoutes.get('/jellyfin/users', async (req, res) => {

jellyfinClient.setUserId(admin.jellyfinUserId ?? '');
const resp = await jellyfinClient.getUsers();
const users = resp.users.map((user) => ({
username: user.Name,
id: user.Id,
thumb: `/avatarproxy/${user.Id}`,
email: user.Name,
}));

return res.status(200).json(users);
const jellyfinUserIds = resp.users
.map((user) => normalizeJellyfinGuid(user.Id))
.filter((id): id is string => !!id);

const existingUsers = jellyfinUserIds.length
? await userRepository
.createQueryBuilder('user')
.select(['user.jellyfinUserId'])
.where(
"LOWER(REPLACE(user.jellyfinUserId, '-', '')) IN (:...jellyfinUserIds)",
{ jellyfinUserIds }
)
.getMany()
: [];
const existingUserIds = new Set(
existingUsers
.map((user) => normalizeJellyfinGuid(user.jellyfinUserId))
.filter((id): id is string => !!id)
);

const unimportedUsers = resp.users
.filter((user) => !existingUserIds.has(normalizeJellyfinGuid(user.Id)))
.map((user) => ({
username: user.Name,
id: user.Id,
thumb: `/avatarproxy/${user.Id}`,
email: user.Name,
}));

return res.status(200).json(unimportedUsers);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
});

settingsRoutes.get('/jellyfin/sync', (_req, res) => {
Expand Down
Loading