import got, { CancelableRequest, Options as GotOptions, RequestError } from 'got'
import { join } from 'path'
import { CONFIG } from '../initializers/config'
-import { ACTIVITY_PUB, PEERTUBE_VERSION, WEBSERVER } from '../initializers/constants'
+import { ACTIVITY_PUB, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants'
import { pipelinePromise } from './core-utils'
import { processImage } from './image-utils'
import { logger } from './logger'
key: string
headers: string[]
}
+ timeout?: number
jsonResponse?: boolean
} & Pick<GotOptions, 'headers' | 'json' | 'method' | 'searchParams'>
path
}, httpSignatureOptions)
}
+ },
+
+ (options: GotOptions) => {
+ options.timeout = REQUEST_TIMEOUT
}
]
}
method: options.method,
json: options.json,
searchParams: options.searchParams,
+ timeout: options.timeout ?? REQUEST_TIMEOUT,
headers,
context
}
import * as WebFinger from 'webfinger.js'
import { isTestInstance } from '@server/helpers/core-utils'
import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
-import { WEBSERVER } from '@server/initializers/constants'
+import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants'
import { ActorModel } from '@server/models/actor/actor'
import { MActorFull } from '@server/types/models'
import { WebFingerData } from '@shared/models'
webfist_fallback: false,
tls_only: isTestInstance(),
uri_fallback: false,
- request_timeout: 3000
+ request_timeout: REQUEST_TIMEOUT
})
async function loadActorUrlOrGetFromWebfinger (uriArg: string) {
import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
import { logger } from '../../helpers/logger'
import { doJSONRequest } from '../../helpers/requests'
-import { ACTIVITY_PUB, REQUEST_TIMEOUT, WEBSERVER } from '../../initializers/constants'
+import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants'
type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>)
type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>)
logger.info('Crawling ActivityPub data on %s.', url)
- const options = {
- activityPub: true,
- timeout: REQUEST_TIMEOUT
- }
+ const options = { activityPub: true }
const startDate = new Date()
import { ActivitypubHttpBroadcastPayload } from '@shared/models'
import { logger } from '../../../helpers/logger'
import { doRequest } from '../../../helpers/requests'
-import { BROADCAST_CONCURRENCY, REQUEST_TIMEOUT } from '../../../initializers/constants'
+import { BROADCAST_CONCURRENCY } from '../../../initializers/constants'
import { ActorFollowScoreCache } from '../../files-cache'
import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
method: 'POST' as 'POST',
json: body,
httpSignature: httpSignatureOptions,
- timeout: REQUEST_TIMEOUT,
headers: buildGlobalHeaders(body)
}
import { ActivitypubHttpUnicastPayload } from '@shared/models'
import { logger } from '../../../helpers/logger'
import { doRequest } from '../../../helpers/requests'
-import { REQUEST_TIMEOUT } from '../../../initializers/constants'
import { ActorFollowScoreCache } from '../../files-cache'
import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
method: 'POST' as 'POST',
json: body,
httpSignature: httpSignatureOptions,
- timeout: REQUEST_TIMEOUT,
headers: buildGlobalHeaders(body)
}