mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Add scores to follows and remove bad ones
This commit is contained in:
parent
7ae71355c4
commit
60650c77c8
21 changed files with 217 additions and 133 deletions
|
@ -1,5 +1,6 @@
|
|||
import { logger } from '../../../helpers/logger'
|
||||
import { doRequest } from '../../../helpers/requests'
|
||||
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
|
||||
import { ActivityPubHttpPayload, buildSignedRequestOptions, computeBody, maybeRetryRequestLater } from './activitypub-http-job-scheduler'
|
||||
|
||||
async function process (payload: ActivityPubHttpPayload, jobId: number) {
|
||||
|
@ -15,15 +16,22 @@ async function process (payload: ActivityPubHttpPayload, jobId: number) {
|
|||
httpSignature: httpSignatureOptions
|
||||
}
|
||||
|
||||
const badUrls: string[] = []
|
||||
const goodUrls: string[] = []
|
||||
|
||||
for (const uri of payload.uris) {
|
||||
options.uri = uri
|
||||
|
||||
try {
|
||||
await doRequest(options)
|
||||
goodUrls.push(uri)
|
||||
} catch (err) {
|
||||
await maybeRetryRequestLater(err, payload, uri)
|
||||
const isRetryingLater = await maybeRetryRequestLater(err, payload, uri)
|
||||
if (isRetryingLater === false) badUrls.push(uri)
|
||||
}
|
||||
}
|
||||
|
||||
return ActorFollowModel.updateActorFollowsScoreAndRemoveBadOnes(goodUrls, badUrls, undefined)
|
||||
}
|
||||
|
||||
function onError (err: Error, jobId: number) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue