X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fschedulers%2Fauto-follow-index-instances.ts;h=0b8cd13898118f815158a14b645508ecf0e6cf2a;hb=db4b15f21fbf4e33434e930ffc7fb768cdcf9d42;hp=a57436a4566d79fb9f77051f3d617b4d13a6a170;hpb=610d0be13b3d01f653ef269271dd667a57c85ef2;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/schedulers/auto-follow-index-instances.ts b/server/lib/schedulers/auto-follow-index-instances.ts index a57436a45..0b8cd1389 100644 --- a/server/lib/schedulers/auto-follow-index-instances.ts +++ b/server/lib/schedulers/auto-follow-index-instances.ts @@ -1,12 +1,12 @@ -import { logger } from '../../helpers/logger' -import { AbstractScheduler } from './abstract-scheduler' -import { INSTANCES_INDEX, SCHEDULER_INTERVALS_MS, SERVER_ACTOR_NAME } from '../../initializers/constants' -import { CONFIG } from '../../initializers/config' import { chunk } from 'lodash' -import { doRequest } from '@server/helpers/requests' -import { ActorFollowModel } from '@server/models/activitypub/actor-follow' +import { doJSONRequest } from '@server/helpers/requests' import { JobQueue } from '@server/lib/job-queue' +import { ActorFollowModel } from '@server/models/activitypub/actor-follow' import { getServerActor } from '@server/models/application/application' +import { logger } from '../../helpers/logger' +import { CONFIG } from '../../initializers/config' +import { SCHEDULER_INTERVALS_MS, SERVER_ACTOR_NAME } from '../../initializers/constants' +import { AbstractScheduler } from './abstract-scheduler' export class AutoFollowIndexInstances extends AbstractScheduler { @@ -34,16 +34,14 @@ export class AutoFollowIndexInstances extends AbstractScheduler { try { const serverActor = await getServerActor() - const uri = indexUrl + INSTANCES_INDEX.HOSTS_PATH - - const qs = { count: 1000 } - if (this.lastCheck) Object.assign(qs, { since: this.lastCheck.toISOString() }) + const searchParams = { count: 1000 } + if (this.lastCheck) Object.assign(searchParams, { since: this.lastCheck.toISOString() }) this.lastCheck = new Date() - const { body } = await doRequest({ uri, qs, json: true }) + const { body } = await doJSONRequest(indexUrl, { searchParams }) if (!body.data || Array.isArray(body.data) === false) { - logger.error('Cannot auto follow instances of index %s: bad URL format. Please check the auto follow URL.', indexUrl) + logger.error('Cannot auto follow instances of index %s. Please check the auto follow URL.', indexUrl, { body }) return }