1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Refractor retry transaction function

This commit is contained in:
Chocobozzz 2018-06-13 14:27:40 +02:00
parent 3cd0734fd9
commit 90d4bb8125
No known key found for this signature in database
GPG key ID: 583A612D890159BE
19 changed files with 162 additions and 415 deletions

View file

@ -11,7 +11,7 @@ async function processFollowActivity (activity: ActivityFollow) {
const activityObject = activity.object
const actor = await getOrCreateActorAndServerAndModel(activity.actor)
return processFollow(actor, activityObject)
return retryTransactionWrapper(processFollow, actor, activityObject)
}
// ---------------------------------------------------------------------------
@ -22,16 +22,7 @@ export {
// ---------------------------------------------------------------------------
function processFollow (actor: ActorModel, targetActorURL: string) {
const options = {
arguments: [ actor, targetActorURL ],
errorMessage: 'Cannot follow with many retries.'
}
return retryTransactionWrapper(follow, options)
}
async function follow (actor: ActorModel, targetActorURL: string) {
async function processFollow (actor: ActorModel, targetActorURL: string) {
await sequelizeTypescript.transaction(async t => {
const targetActor = await ActorModel.loadByUrl(targetActorURL, t)