Redis.Instance.init()
// Make server listening
- server.listen(port, hostname)
- logger.info('Server listening on %s:%d', hostname, port)
- logger.info('Web server: %s', CONFIG.WEBSERVER.URL)
+ server.listen(port, hostname, () => {
+ logger.info('Server listening on %s:%d', hostname, port)
+ logger.info('Web server: %s', CONFIG.WEBSERVER.URL)
+ })
}
'video-file': 1,
'email': 5
}
+const BROADCAST_CONCURRENCY = 5 // How many requests in parallel we do in activitypub-http-broadcast job
// 2 days
const JOB_COMPLETED_LIFETIME = 60000 * 60 * 24 * 2
LAST_MIGRATION_VERSION,
OAUTH_LIFETIME,
OPENGRAPH_AND_OEMBED_COMMENT,
+ BROADCAST_CONCURRENCY,
PAGINATION_COUNT_DEFAULT,
ACTOR_FOLLOW_SCORE,
PREVIEWS_SIZE,
import * as kue from 'kue'
+import * as Bluebird from 'bluebird'
import { logger } from '../../../helpers/logger'
import { doRequest } from '../../../helpers/requests'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
+import { BROADCAST_CONCURRENCY } from '../../../initializers'
export type ActivitypubHttpBroadcastPayload = {
uris: string[]
const badUrls: string[] = []
const goodUrls: string[] = []
- for (const uri of payload.uris) {
- options.uri = uri
-
- try {
- await doRequest(options)
- goodUrls.push(uri)
- } catch (err) {
- badUrls.push(uri)
- }
- }
+ await Bluebird.map(payload.uris, uri => {
+ return doRequest(Object.assign({}, options, { uri }))
+ .then(() => goodUrls.push(uri))
+ .catch(() => badUrls.push(uri))
+ }, { concurrency: BROADCAST_CONCURRENCY })
return ActorFollowModel.updateActorFollowsScore(goodUrls, badUrls, undefined)
}