diff options
Diffstat (limited to 'server/lib/activitypub/process/process-delete.ts')
-rw-r--r-- | server/lib/activitypub/process/process-delete.ts | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts index 8310b70f0..ff0caa343 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/lib/activitypub/process/process-delete.ts | |||
@@ -21,12 +21,12 @@ async function processDeleteActivity (activity: ActivityDelete) { | |||
21 | if (!actor.Account) throw new Error('Actor ' + actor.url + ' is a person but we cannot find it in database.') | 21 | if (!actor.Account) throw new Error('Actor ' + actor.url + ' is a person but we cannot find it in database.') |
22 | 22 | ||
23 | actor.Account.Actor = await actor.Account.$get('Actor') as ActorModel | 23 | actor.Account.Actor = await actor.Account.$get('Actor') as ActorModel |
24 | return processDeleteAccount(actor.Account) | 24 | return retryTransactionWrapper(processDeleteAccount, actor.Account) |
25 | } else if (actor.type === 'Group') { | 25 | } else if (actor.type === 'Group') { |
26 | if (!actor.VideoChannel) throw new Error('Actor ' + actor.url + ' is a group but we cannot find it in database.') | 26 | if (!actor.VideoChannel) throw new Error('Actor ' + actor.url + ' is a group but we cannot find it in database.') |
27 | 27 | ||
28 | actor.VideoChannel.Actor = await actor.VideoChannel.$get('Actor') as ActorModel | 28 | actor.VideoChannel.Actor = await actor.VideoChannel.$get('Actor') as ActorModel |
29 | return processDeleteVideoChannel(actor.VideoChannel) | 29 | return retryTransactionWrapper(processDeleteVideoChannel, actor.VideoChannel) |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
@@ -34,14 +34,14 @@ async function processDeleteActivity (activity: ActivityDelete) { | |||
34 | { | 34 | { |
35 | const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(objectUrl) | 35 | const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(objectUrl) |
36 | if (videoCommentInstance) { | 36 | if (videoCommentInstance) { |
37 | return processDeleteVideoComment(actor, videoCommentInstance, activity) | 37 | return retryTransactionWrapper(processDeleteVideoComment, actor, videoCommentInstance, activity) |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | { | 41 | { |
42 | const videoInstance = await VideoModel.loadByUrlAndPopulateAccount(objectUrl) | 42 | const videoInstance = await VideoModel.loadByUrlAndPopulateAccount(objectUrl) |
43 | if (videoInstance) { | 43 | if (videoInstance) { |
44 | return processDeleteVideo(actor, videoInstance) | 44 | return retryTransactionWrapper(processDeleteVideo, actor, videoInstance) |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
@@ -57,15 +57,6 @@ export { | |||
57 | // --------------------------------------------------------------------------- | 57 | // --------------------------------------------------------------------------- |
58 | 58 | ||
59 | async function processDeleteVideo (actor: ActorModel, videoToDelete: VideoModel) { | 59 | async function processDeleteVideo (actor: ActorModel, videoToDelete: VideoModel) { |
60 | const options = { | ||
61 | arguments: [ actor, videoToDelete ], | ||
62 | errorMessage: 'Cannot remove the remote video with many retries.' | ||
63 | } | ||
64 | |||
65 | await retryTransactionWrapper(deleteRemoteVideo, options) | ||
66 | } | ||
67 | |||
68 | async function deleteRemoteVideo (actor: ActorModel, videoToDelete: VideoModel) { | ||
69 | logger.debug('Removing remote video "%s".', videoToDelete.uuid) | 60 | logger.debug('Removing remote video "%s".', videoToDelete.uuid) |
70 | 61 | ||
71 | await sequelizeTypescript.transaction(async t => { | 62 | await sequelizeTypescript.transaction(async t => { |
@@ -80,15 +71,6 @@ async function deleteRemoteVideo (actor: ActorModel, videoToDelete: VideoModel) | |||
80 | } | 71 | } |
81 | 72 | ||
82 | async function processDeleteAccount (accountToRemove: AccountModel) { | 73 | async function processDeleteAccount (accountToRemove: AccountModel) { |
83 | const options = { | ||
84 | arguments: [ accountToRemove ], | ||
85 | errorMessage: 'Cannot remove the remote account with many retries.' | ||
86 | } | ||
87 | |||
88 | await retryTransactionWrapper(deleteRemoteAccount, options) | ||
89 | } | ||
90 | |||
91 | async function deleteRemoteAccount (accountToRemove: AccountModel) { | ||
92 | logger.debug('Removing remote account "%s".', accountToRemove.Actor.uuid) | 74 | logger.debug('Removing remote account "%s".', accountToRemove.Actor.uuid) |
93 | 75 | ||
94 | await sequelizeTypescript.transaction(async t => { | 76 | await sequelizeTypescript.transaction(async t => { |
@@ -99,15 +81,6 @@ async function deleteRemoteAccount (accountToRemove: AccountModel) { | |||
99 | } | 81 | } |
100 | 82 | ||
101 | async function processDeleteVideoChannel (videoChannelToRemove: VideoChannelModel) { | 83 | async function processDeleteVideoChannel (videoChannelToRemove: VideoChannelModel) { |
102 | const options = { | ||
103 | arguments: [ videoChannelToRemove ], | ||
104 | errorMessage: 'Cannot remove the remote video channel with many retries.' | ||
105 | } | ||
106 | |||
107 | await retryTransactionWrapper(deleteRemoteVideoChannel, options) | ||
108 | } | ||
109 | |||
110 | async function deleteRemoteVideoChannel (videoChannelToRemove: VideoChannelModel) { | ||
111 | logger.debug('Removing remote video channel "%s".', videoChannelToRemove.Actor.uuid) | 84 | logger.debug('Removing remote video channel "%s".', videoChannelToRemove.Actor.uuid) |
112 | 85 | ||
113 | await sequelizeTypescript.transaction(async t => { | 86 | await sequelizeTypescript.transaction(async t => { |
@@ -117,16 +90,7 @@ async function deleteRemoteVideoChannel (videoChannelToRemove: VideoChannelModel | |||
117 | logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.Actor.uuid) | 90 | logger.info('Remote video channel with uuid %s removed.', videoChannelToRemove.Actor.uuid) |
118 | } | 91 | } |
119 | 92 | ||
120 | async function processDeleteVideoComment (byActor: ActorModel, videoComment: VideoCommentModel, activity: ActivityDelete) { | 93 | function processDeleteVideoComment (byActor: ActorModel, videoComment: VideoCommentModel, activity: ActivityDelete) { |
121 | const options = { | ||
122 | arguments: [ byActor, videoComment, activity ], | ||
123 | errorMessage: 'Cannot remove the remote video comment with many retries.' | ||
124 | } | ||
125 | |||
126 | await retryTransactionWrapper(deleteRemoteVideoComment, options) | ||
127 | } | ||
128 | |||
129 | function deleteRemoteVideoComment (byActor: ActorModel, videoComment: VideoCommentModel, activity: ActivityDelete) { | ||
130 | logger.debug('Removing remote video comment "%s".', videoComment.url) | 94 | logger.debug('Removing remote video comment "%s".', videoComment.url) |
131 | 95 | ||
132 | return sequelizeTypescript.transaction(async t => { | 96 | return sequelizeTypescript.transaction(async t => { |