Skip to content

Commit

Permalink
fix(plex-sync): do not run plex sync if no admin exists
Browse files Browse the repository at this point in the history
  • Loading branch information
sct committed Jan 6, 2021
1 parent e2c2172 commit 493d82b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/job/plexsync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class JobPlexSync {

private log(
message: string,
level: 'info' | 'error' | 'debug' = 'debug',
level: 'info' | 'error' | 'debug' | 'warn' = 'debug',
optional?: Record<string, unknown>
): void {
logger[level](message, { label: 'Plex Sync', ...optional });
Expand All @@ -356,11 +356,15 @@ class JobPlexSync {
if (!this.running) {
this.running = true;
const userRepository = getRepository(User);
const admin = await userRepository.findOneOrFail({
const admin = await userRepository.findOne({
select: ['id', 'plexToken'],
order: { id: 'ASC' },
});

if (!admin) {
return this.log('No admin configured. Plex sync skipped.', 'warn');
}

this.plexClient = new PlexAPI({ plexToken: admin.plexToken });

this.libraries = settings.plex.libraries.filter(
Expand Down

0 comments on commit 493d82b

Please sign in to comment.