diff options
Diffstat (limited to 'server/lib/schedulers/auto-follow-index-instances.ts')
-rw-r--r-- | server/lib/schedulers/auto-follow-index-instances.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/server/lib/schedulers/auto-follow-index-instances.ts b/server/lib/schedulers/auto-follow-index-instances.ts index dd326bc1e..a57436a45 100644 --- a/server/lib/schedulers/auto-follow-index-instances.ts +++ b/server/lib/schedulers/auto-follow-index-instances.ts | |||
@@ -6,7 +6,7 @@ import { chunk } from 'lodash' | |||
6 | import { doRequest } from '@server/helpers/requests' | 6 | import { doRequest } from '@server/helpers/requests' |
7 | import { ActorFollowModel } from '@server/models/activitypub/actor-follow' | 7 | import { ActorFollowModel } from '@server/models/activitypub/actor-follow' |
8 | import { JobQueue } from '@server/lib/job-queue' | 8 | import { JobQueue } from '@server/lib/job-queue' |
9 | import { getServerActor } from '@server/helpers/utils' | 9 | import { getServerActor } from '@server/models/application/application' |
10 | 10 | ||
11 | export class AutoFollowIndexInstances extends AbstractScheduler { | 11 | export class AutoFollowIndexInstances extends AbstractScheduler { |
12 | 12 | ||
@@ -41,7 +41,11 @@ export class AutoFollowIndexInstances extends AbstractScheduler { | |||
41 | 41 | ||
42 | this.lastCheck = new Date() | 42 | this.lastCheck = new Date() |
43 | 43 | ||
44 | const { body } = await doRequest({ uri, qs, json: true }) | 44 | const { body } = await doRequest<any>({ uri, qs, json: true }) |
45 | if (!body.data || Array.isArray(body.data) === false) { | ||
46 | logger.error('Cannot auto follow instances of index %s: bad URL format. Please check the auto follow URL.', indexUrl) | ||
47 | return | ||
48 | } | ||
45 | 49 | ||
46 | const hosts: string[] = body.data.map(o => o.host) | 50 | const hosts: string[] = body.data.map(o => o.host) |
47 | const chunks = chunk(hosts, 20) | 51 | const chunks = chunk(hosts, 20) |
@@ -57,8 +61,7 @@ export class AutoFollowIndexInstances extends AbstractScheduler { | |||
57 | isAutoFollow: true | 61 | isAutoFollow: true |
58 | } | 62 | } |
59 | 63 | ||
60 | await JobQueue.Instance.createJob({ type: 'activitypub-follow', payload }) | 64 | JobQueue.Instance.createJob({ type: 'activitypub-follow', payload }) |
61 | .catch(err => logger.error('Cannot create follow job for %s.', unfollowedHost, err)) | ||
62 | } | 65 | } |
63 | } | 66 | } |
64 | 67 | ||