Filter instance in bulk

This commit is contained in:
Chocobozzz 2024-01-04 14:39:41 +01:00
parent fde7007788
commit 69e17e2777
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 7 additions and 3 deletions

View File

@ -29,6 +29,7 @@ instances-index:
- 'replay.jres.org'
- 'tube.nah.re'
- 'video.passageenseine.fr'
- 'peertube.luga.at'
api:
blacklist:

View File

@ -2,6 +2,7 @@ import { CONFIG } from '../../initializers/constants'
import { listIndexInstancesHost, getMajorInstanceVersion } from '../requests/instances-index'
import { client } from '../../helpers/meilisearch'
import { logger } from '../../helpers/logger'
import Bluebird from 'bluebird'
async function buildInstanceHosts () {
let indexHosts = await listIndexInstancesHost()
@ -14,15 +15,17 @@ async function buildInstanceHosts () {
indexHosts = indexHosts.filter(h => whitelistHosts.includes(h))
}
for (const indexHost of indexHosts) {
indexHosts = await Bluebird.filter(indexHosts, async indexHost => {
const instanceVersion = await getMajorInstanceVersion(indexHost)
if (instanceVersion < 4) {
logger.info(`Do not index ${indexHost} because the major version is too low (v${instanceVersion} < v4)`)
indexHosts = indexHosts.filter(h => h !== indexHost)
return false
}
}
return true
}, { concurrency: 10 })
const dbHosts = await listDBInstances()
const removedHosts = getRemovedHosts(dbHosts, indexHosts)