Fix auto follow index URL
This commit is contained in:
parent
5ca8c03e1d
commit
2ca154da93
4 changed files with 9 additions and 16 deletions
|
@ -178,10 +178,6 @@ const SCHEDULER_INTERVALS_MS = {
|
||||||
removeOldHistory: 60000 * 60 * 24 // 1 day
|
removeOldHistory: 60000 * 60 * 24 // 1 day
|
||||||
}
|
}
|
||||||
|
|
||||||
const INSTANCES_INDEX = {
|
|
||||||
HOSTS_PATH: '/api/v1/instances/hosts'
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
const CONSTRAINTS_FIELDS = {
|
const CONSTRAINTS_FIELDS = {
|
||||||
|
@ -730,7 +726,6 @@ export {
|
||||||
PREVIEWS_SIZE,
|
PREVIEWS_SIZE,
|
||||||
REMOTE_SCHEME,
|
REMOTE_SCHEME,
|
||||||
FOLLOW_STATES,
|
FOLLOW_STATES,
|
||||||
INSTANCES_INDEX,
|
|
||||||
DEFAULT_USER_THEME_NAME,
|
DEFAULT_USER_THEME_NAME,
|
||||||
SERVER_ACTOR_NAME,
|
SERVER_ACTOR_NAME,
|
||||||
PLUGIN_GLOBAL_CSS_FILE_NAME,
|
PLUGIN_GLOBAL_CSS_FILE_NAME,
|
||||||
|
|
|
@ -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 { chunk } from 'lodash'
|
||||||
import { doRequest } from '@server/helpers/requests'
|
import { doRequest } from '@server/helpers/requests'
|
||||||
import { ActorFollowModel } from '@server/models/activitypub/actor-follow'
|
|
||||||
import { JobQueue } from '@server/lib/job-queue'
|
import { JobQueue } from '@server/lib/job-queue'
|
||||||
|
import { ActorFollowModel } from '@server/models/activitypub/actor-follow'
|
||||||
import { getServerActor } from '@server/models/application/application'
|
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 {
|
export class AutoFollowIndexInstances extends AbstractScheduler {
|
||||||
|
|
||||||
|
@ -34,16 +34,14 @@ export class AutoFollowIndexInstances extends AbstractScheduler {
|
||||||
try {
|
try {
|
||||||
const serverActor = await getServerActor()
|
const serverActor = await getServerActor()
|
||||||
|
|
||||||
const uri = indexUrl + INSTANCES_INDEX.HOSTS_PATH
|
|
||||||
|
|
||||||
const qs = { count: 1000 }
|
const qs = { count: 1000 }
|
||||||
if (this.lastCheck) Object.assign(qs, { since: this.lastCheck.toISOString() })
|
if (this.lastCheck) Object.assign(qs, { since: this.lastCheck.toISOString() })
|
||||||
|
|
||||||
this.lastCheck = new Date()
|
this.lastCheck = new Date()
|
||||||
|
|
||||||
const { body } = await doRequest<any>({ uri, qs, json: true })
|
const { body } = await doRequest<any>({ uri: indexUrl, qs, json: true })
|
||||||
if (!body.data || Array.isArray(body.data) === false) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ describe('Test auto follows', function () {
|
||||||
followings: {
|
followings: {
|
||||||
instance: {
|
instance: {
|
||||||
autoFollowIndex: {
|
autoFollowIndex: {
|
||||||
indexUrl: 'http://localhost:42100/api/v1/instances/hosts',
|
indexUrl: 'http://localhost:42101/api/v1/instances/hosts',
|
||||||
enabled: true
|
enabled: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export class MockInstancesIndex {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
app.listen(42100, () => res())
|
app.listen(42101, () => res())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue