1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +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

@ -25,9 +25,9 @@ async function processUpdateActivity (activity: ActivityUpdate) {
const objectType = activity.object.type
if (objectType === 'Video') {
return processUpdateVideo(actor, activity)
return retryTransactionWrapper(processUpdateVideo, actor, activity)
} else if (objectType === 'Person' || objectType === 'Application' || objectType === 'Group') {
return processUpdateActor(actor, activity)
return retryTransactionWrapper(processUpdateActor, actor, activity)
}
return undefined
@ -41,16 +41,7 @@ export {
// ---------------------------------------------------------------------------
function processUpdateVideo (actor: ActorModel, activity: ActivityUpdate) {
const options = {
arguments: [ actor, activity ],
errorMessage: 'Cannot update the remote video with many retries'
}
return retryTransactionWrapper(updateRemoteVideo, options)
}
async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
async function processUpdateVideo (actor: ActorModel, activity: ActivityUpdate) {
const videoObject = activity.object as VideoTorrentObject
if (sanitizeAndCheckVideoTorrentObject(videoObject) === false) {
@ -136,16 +127,7 @@ async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
}
}
function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) {
const options = {
arguments: [ actor, activity ],
errorMessage: 'Cannot update the remote actor with many retries'
}
return retryTransactionWrapper(updateRemoteActor, options)
}
async function updateRemoteActor (actor: ActorModel, activity: ActivityUpdate) {
async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) {
const actorAttributesToUpdate = activity.object as ActivityPubActor
logger.debug('Updating remote account "%s".', actorAttributesToUpdate.uuid)