Fix request version error

This commit is contained in:
Chocobozzz 2023-12-20 16:30:54 +01:00
parent 0a210321ea
commit 4502709205
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 10 additions and 7 deletions

View File

@ -15,13 +15,17 @@ export async function listIndexInstancesHost (): Promise<string[]> {
}
export async function getMajorInstanceVersion (host: string): Promise<number> {
const { body } = await doRequest<any>({ uri: `https://${host}/api/v1/config`, json: true })
try {
const { body } = await doRequest<any>({ uri: `https://${host}/api/v1/config`, json: true })
const version = body.serverVersion
const version = body.serverVersion
const majorVersion = parseInt(version.split('.')[0])
const majorVersion = parseInt(version.split('.')[0])
return isNaN(majorVersion)
? 0
: majorVersion
return isNaN(majorVersion)
? 0
: majorVersion
} catch {
return 0
}
}

View File

@ -10,7 +10,6 @@ import { PlaylistIndexer } from '../indexers/playlist-indexer'
import { VideoIndexer } from '../indexers/video-indexer'
import { getPlaylistsOf, getVideos } from '../requests/peertube-instance'
import { AbstractScheduler } from './abstract-scheduler'
import { getMajorInstanceVersion } from '../requests/instances-index'
export class IndexationScheduler extends AbstractScheduler {