diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-13 14:27:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-13 14:27:40 +0200 |
commit | 90d4bb8125e80c8060416d4d135ddeaf0a622ede (patch) | |
tree | b3b7181329a08ecc930b54fe7b48095c4155393c /server/lib/activitypub/process/process-update.ts | |
parent | 3cd0734fd9b0ff21aaef02317a874e8f1c06e027 (diff) | |
download | PeerTube-90d4bb8125e80c8060416d4d135ddeaf0a622ede.tar.gz PeerTube-90d4bb8125e80c8060416d4d135ddeaf0a622ede.tar.zst PeerTube-90d4bb8125e80c8060416d4d135ddeaf0a622ede.zip |
Refractor retry transaction function
Diffstat (limited to 'server/lib/activitypub/process/process-update.ts')
-rw-r--r-- | server/lib/activitypub/process/process-update.ts | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts index 1ebda46d3..73db461c3 100644 --- a/server/lib/activitypub/process/process-update.ts +++ b/server/lib/activitypub/process/process-update.ts | |||
@@ -25,9 +25,9 @@ async function processUpdateActivity (activity: ActivityUpdate) { | |||
25 | const objectType = activity.object.type | 25 | const objectType = activity.object.type |
26 | 26 | ||
27 | if (objectType === 'Video') { | 27 | if (objectType === 'Video') { |
28 | return processUpdateVideo(actor, activity) | 28 | return retryTransactionWrapper(processUpdateVideo, actor, activity) |
29 | } else if (objectType === 'Person' || objectType === 'Application' || objectType === 'Group') { | 29 | } else if (objectType === 'Person' || objectType === 'Application' || objectType === 'Group') { |
30 | return processUpdateActor(actor, activity) | 30 | return retryTransactionWrapper(processUpdateActor, actor, activity) |
31 | } | 31 | } |
32 | 32 | ||
33 | return undefined | 33 | return undefined |
@@ -41,16 +41,7 @@ export { | |||
41 | 41 | ||
42 | // --------------------------------------------------------------------------- | 42 | // --------------------------------------------------------------------------- |
43 | 43 | ||
44 | function processUpdateVideo (actor: ActorModel, activity: ActivityUpdate) { | 44 | async function processUpdateVideo (actor: ActorModel, activity: ActivityUpdate) { |
45 | const options = { | ||
46 | arguments: [ actor, activity ], | ||
47 | errorMessage: 'Cannot update the remote video with many retries' | ||
48 | } | ||
49 | |||
50 | return retryTransactionWrapper(updateRemoteVideo, options) | ||
51 | } | ||
52 | |||
53 | async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) { | ||
54 | const videoObject = activity.object as VideoTorrentObject | 45 | const videoObject = activity.object as VideoTorrentObject |
55 | 46 | ||
56 | if (sanitizeAndCheckVideoTorrentObject(videoObject) === false) { | 47 | if (sanitizeAndCheckVideoTorrentObject(videoObject) === false) { |
@@ -136,16 +127,7 @@ async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) { | |||
136 | } | 127 | } |
137 | } | 128 | } |
138 | 129 | ||
139 | function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) { | 130 | async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) { |
140 | const options = { | ||
141 | arguments: [ actor, activity ], | ||
142 | errorMessage: 'Cannot update the remote actor with many retries' | ||
143 | } | ||
144 | |||
145 | return retryTransactionWrapper(updateRemoteActor, options) | ||
146 | } | ||
147 | |||
148 | async function updateRemoteActor (actor: ActorModel, activity: ActivityUpdate) { | ||
149 | const actorAttributesToUpdate = activity.object as ActivityPubActor | 131 | const actorAttributesToUpdate = activity.object as ActivityPubActor |
150 | 132 | ||
151 | logger.debug('Updating remote account "%s".', actorAttributesToUpdate.uuid) | 133 | logger.debug('Updating remote account "%s".', actorAttributesToUpdate.uuid) |