aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-12 09:37:39 +0200
committerChocobozzz <me@florianbigard.com>2020-05-12 09:37:39 +0200
commit2ca154da93acb7b87a12f6a9477d90cfb2a10475 (patch)
tree5843af40eadb28c6ccbc8a9887c40f84ec8423c3
parent5ca8c03e1dc172813d65397954ee785d462d83aa (diff)
downloadPeerTube-2ca154da93acb7b87a12f6a9477d90cfb2a10475.tar.gz
PeerTube-2ca154da93acb7b87a12f6a9477d90cfb2a10475.tar.zst
PeerTube-2ca154da93acb7b87a12f6a9477d90cfb2a10475.zip
Fix auto follow index URL
-rw-r--r--server/initializers/constants.ts5
-rw-r--r--server/lib/schedulers/auto-follow-index-instances.ts16
-rw-r--r--server/tests/api/server/auto-follows.ts2
-rw-r--r--shared/extra-utils/instances-index/mock-instances-index.ts2
4 files changed, 9 insertions, 16 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
181const INSTANCES_INDEX = {
182 HOSTS_PATH: '/api/v1/instances/hosts'
183}
184
185// --------------------------------------------------------------------------- 181// ---------------------------------------------------------------------------
186 182
187const CONSTRAINTS_FIELDS = { 183const 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 @@
1import { logger } from '../../helpers/logger'
2import { AbstractScheduler } from './abstract-scheduler'
3import { INSTANCES_INDEX, SCHEDULER_INTERVALS_MS, SERVER_ACTOR_NAME } from '../../initializers/constants'
4import { CONFIG } from '../../initializers/config'
5import { chunk } from 'lodash' 1import { chunk } from 'lodash'
6import { doRequest } from '@server/helpers/requests' 2import { doRequest } from '@server/helpers/requests'
7import { ActorFollowModel } from '@server/models/activitypub/actor-follow'
8import { JobQueue } from '@server/lib/job-queue' 3import { JobQueue } from '@server/lib/job-queue'
4import { ActorFollowModel } from '@server/models/activitypub/actor-follow'
9import { getServerActor } from '@server/models/application/application' 5import { getServerActor } from '@server/models/application/application'
6import { logger } from '../../helpers/logger'
7import { CONFIG } from '../../initializers/config'
8import { SCHEDULER_INTERVALS_MS, SERVER_ACTOR_NAME } from '../../initializers/constants'
9import { AbstractScheduler } from './abstract-scheduler'
10 10
11export class AutoFollowIndexInstances extends AbstractScheduler { 11export 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 }
diff --git a/shared/extra-utils/instances-index/mock-instances-index.ts b/shared/extra-utils/instances-index/mock-instances-index.ts
index c58e8bcf8..ea09c9f61 100644
--- a/shared/extra-utils/instances-index/mock-instances-index.ts
+++ b/shared/extra-utils/instances-index/mock-instances-index.ts
@@ -28,7 +28,7 @@ export class MockInstancesIndex {
28 }) 28 })
29 }) 29 })
30 30
31 app.listen(42100, () => res()) 31 app.listen(42101, () => res())
32 }) 32 })
33 } 33 }
34 34