diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-12 09:37:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-05-12 09:37:39 +0200 |
commit | 2ca154da93acb7b87a12f6a9477d90cfb2a10475 (patch) | |
tree | 5843af40eadb28c6ccbc8a9887c40f84ec8423c3 /server | |
parent | 5ca8c03e1dc172813d65397954ee785d462d83aa (diff) | |
download | PeerTube-2ca154da93acb7b87a12f6a9477d90cfb2a10475.tar.gz PeerTube-2ca154da93acb7b87a12f6a9477d90cfb2a10475.tar.zst PeerTube-2ca154da93acb7b87a12f6a9477d90cfb2a10475.zip |
Fix auto follow index URL
Diffstat (limited to 'server')
-rw-r--r-- | server/initializers/constants.ts | 5 | ||||
-rw-r--r-- | server/lib/schedulers/auto-follow-index-instances.ts | 16 | ||||
-rw-r--r-- | server/tests/api/server/auto-follows.ts | 2 |
3 files changed, 8 insertions, 15 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 134560717..e5cac64d4 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -178,10 +178,6 @@ const SCHEDULER_INTERVALS_MS = { | |||
178 | removeOldHistory: 60000 * 60 * 24 // 1 day | 178 | removeOldHistory: 60000 * 60 * 24 // 1 day |
179 | } | 179 | } |
180 | 180 | ||
181 | const INSTANCES_INDEX = { | ||
182 | HOSTS_PATH: '/api/v1/instances/hosts' | ||
183 | } | ||
184 | |||
185 | // --------------------------------------------------------------------------- | 181 | // --------------------------------------------------------------------------- |
186 | 182 | ||
187 | const CONSTRAINTS_FIELDS = { | 183 | const CONSTRAINTS_FIELDS = { |
@@ -730,7 +726,6 @@ export { | |||
730 | PREVIEWS_SIZE, | 726 | PREVIEWS_SIZE, |
731 | REMOTE_SCHEME, | 727 | REMOTE_SCHEME, |
732 | FOLLOW_STATES, | 728 | FOLLOW_STATES, |
733 | INSTANCES_INDEX, | ||
734 | DEFAULT_USER_THEME_NAME, | 729 | DEFAULT_USER_THEME_NAME, |
735 | SERVER_ACTOR_NAME, | 730 | SERVER_ACTOR_NAME, |
736 | PLUGIN_GLOBAL_CSS_FILE_NAME, | 731 | PLUGIN_GLOBAL_CSS_FILE_NAME, |
diff --git a/server/lib/schedulers/auto-follow-index-instances.ts b/server/lib/schedulers/auto-follow-index-instances.ts index a57436a45..f62f52f9c 100644 --- a/server/lib/schedulers/auto-follow-index-instances.ts +++ b/server/lib/schedulers/auto-follow-index-instances.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import { logger } from '../../helpers/logger' | ||
2 | import { AbstractScheduler } from './abstract-scheduler' | ||
3 | import { INSTANCES_INDEX, SCHEDULER_INTERVALS_MS, SERVER_ACTOR_NAME } from '../../initializers/constants' | ||
4 | import { CONFIG } from '../../initializers/config' | ||
5 | import { chunk } from 'lodash' | 1 | import { chunk } from 'lodash' |
6 | import { doRequest } from '@server/helpers/requests' | 2 | import { doRequest } from '@server/helpers/requests' |
7 | import { ActorFollowModel } from '@server/models/activitypub/actor-follow' | ||
8 | import { JobQueue } from '@server/lib/job-queue' | 3 | import { JobQueue } from '@server/lib/job-queue' |
4 | import { ActorFollowModel } from '@server/models/activitypub/actor-follow' | ||
9 | import { getServerActor } from '@server/models/application/application' | 5 | import { getServerActor } from '@server/models/application/application' |
6 | import { logger } from '../../helpers/logger' | ||
7 | import { CONFIG } from '../../initializers/config' | ||
8 | import { SCHEDULER_INTERVALS_MS, SERVER_ACTOR_NAME } from '../../initializers/constants' | ||
9 | import { AbstractScheduler } from './abstract-scheduler' | ||
10 | 10 | ||
11 | export class AutoFollowIndexInstances extends AbstractScheduler { | 11 | export class AutoFollowIndexInstances extends AbstractScheduler { |
12 | 12 | ||
@@ -34,16 +34,14 @@ export class AutoFollowIndexInstances extends AbstractScheduler { | |||
34 | try { | 34 | try { |
35 | const serverActor = await getServerActor() | 35 | const serverActor = await getServerActor() |
36 | 36 | ||
37 | const uri = indexUrl + INSTANCES_INDEX.HOSTS_PATH | ||
38 | |||
39 | const qs = { count: 1000 } | 37 | const qs = { count: 1000 } |
40 | if (this.lastCheck) Object.assign(qs, { since: this.lastCheck.toISOString() }) | 38 | if (this.lastCheck) Object.assign(qs, { since: this.lastCheck.toISOString() }) |
41 | 39 | ||
42 | this.lastCheck = new Date() | 40 | this.lastCheck = new Date() |
43 | 41 | ||
44 | const { body } = await doRequest<any>({ uri, qs, json: true }) | 42 | const { body } = await doRequest<any>({ uri: indexUrl, qs, json: true }) |
45 | if (!body.data || Array.isArray(body.data) === false) { | 43 | 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) | 44 | logger.error('Cannot auto follow instances of index %s. Please check the auto follow URL.', indexUrl, { body }) |
47 | return | 45 | return |
48 | } | 46 | } |
49 | 47 | ||
diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts index 7efccc3e2..e04d70af4 100644 --- a/server/tests/api/server/auto-follows.ts +++ b/server/tests/api/server/auto-follows.ts | |||
@@ -177,7 +177,7 @@ describe('Test auto follows', function () { | |||
177 | followings: { | 177 | followings: { |
178 | instance: { | 178 | instance: { |
179 | autoFollowIndex: { | 179 | autoFollowIndex: { |
180 | indexUrl: 'http://localhost:42100/api/v1/instances/hosts', | 180 | indexUrl: 'http://localhost:42101/api/v1/instances/hosts', |
181 | enabled: true | 181 | enabled: true |
182 | } | 182 | } |
183 | } | 183 | } |