diff options
Diffstat (limited to 'server/lib/activitypub/process/process-create.ts')
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index 38dacf772..6364bf135 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts | |||
@@ -21,13 +21,13 @@ async function processCreateActivity (activity: ActivityCreate) { | |||
21 | if (activityType === 'View') { | 21 | if (activityType === 'View') { |
22 | return processCreateView(actor, activity) | 22 | return processCreateView(actor, activity) |
23 | } else if (activityType === 'Dislike') { | 23 | } else if (activityType === 'Dislike') { |
24 | return processCreateDislike(actor, activity) | 24 | return retryTransactionWrapper(processCreateDislike, actor, activity) |
25 | } else if (activityType === 'Video') { | 25 | } else if (activityType === 'Video') { |
26 | return processCreateVideo(actor, activity) | 26 | return processCreateVideo(actor, activity) |
27 | } else if (activityType === 'Flag') { | 27 | } else if (activityType === 'Flag') { |
28 | return processCreateVideoAbuse(actor, activityObject as VideoAbuseObject) | 28 | return retryTransactionWrapper(processCreateVideoAbuse, actor, activityObject as VideoAbuseObject) |
29 | } else if (activityType === 'Note') { | 29 | } else if (activityType === 'Note') { |
30 | return processCreateVideoComment(actor, activity) | 30 | return retryTransactionWrapper(processCreateVideoComment, actor, activity) |
31 | } | 31 | } |
32 | 32 | ||
33 | logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id }) | 33 | logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id }) |
@@ -54,15 +54,6 @@ async function processCreateVideo ( | |||
54 | } | 54 | } |
55 | 55 | ||
56 | async function processCreateDislike (byActor: ActorModel, activity: ActivityCreate) { | 56 | async function processCreateDislike (byActor: ActorModel, activity: ActivityCreate) { |
57 | const options = { | ||
58 | arguments: [ byActor, activity ], | ||
59 | errorMessage: 'Cannot dislike the video with many retries.' | ||
60 | } | ||
61 | |||
62 | return retryTransactionWrapper(createVideoDislike, options) | ||
63 | } | ||
64 | |||
65 | async function createVideoDislike (byActor: ActorModel, activity: ActivityCreate) { | ||
66 | const dislike = activity.object as DislikeObject | 57 | const dislike = activity.object as DislikeObject |
67 | const byAccount = byActor.Account | 58 | const byAccount = byActor.Account |
68 | 59 | ||
@@ -109,16 +100,7 @@ async function processCreateView (byActor: ActorModel, activity: ActivityCreate) | |||
109 | } | 100 | } |
110 | } | 101 | } |
111 | 102 | ||
112 | function processCreateVideoAbuse (actor: ActorModel, videoAbuseToCreateData: VideoAbuseObject) { | 103 | async function processCreateVideoAbuse (actor: ActorModel, videoAbuseToCreateData: VideoAbuseObject) { |
113 | const options = { | ||
114 | arguments: [ actor, videoAbuseToCreateData ], | ||
115 | errorMessage: 'Cannot insert the remote video abuse with many retries.' | ||
116 | } | ||
117 | |||
118 | return retryTransactionWrapper(addRemoteVideoAbuse, options) | ||
119 | } | ||
120 | |||
121 | async function addRemoteVideoAbuse (actor: ActorModel, videoAbuseToCreateData: VideoAbuseObject) { | ||
122 | logger.debug('Reporting remote abuse for video %s.', videoAbuseToCreateData.object) | 104 | logger.debug('Reporting remote abuse for video %s.', videoAbuseToCreateData.object) |
123 | 105 | ||
124 | const account = actor.Account | 106 | const account = actor.Account |
@@ -139,16 +121,7 @@ async function addRemoteVideoAbuse (actor: ActorModel, videoAbuseToCreateData: V | |||
139 | }) | 121 | }) |
140 | } | 122 | } |
141 | 123 | ||
142 | function processCreateVideoComment (byActor: ActorModel, activity: ActivityCreate) { | 124 | async function processCreateVideoComment (byActor: ActorModel, activity: ActivityCreate) { |
143 | const options = { | ||
144 | arguments: [ byActor, activity ], | ||
145 | errorMessage: 'Cannot create video comment with many retries.' | ||
146 | } | ||
147 | |||
148 | return retryTransactionWrapper(createVideoComment, options) | ||
149 | } | ||
150 | |||
151 | async function createVideoComment (byActor: ActorModel, activity: ActivityCreate) { | ||
152 | const comment = activity.object as VideoCommentObject | 125 | const comment = activity.object as VideoCommentObject |
153 | const byAccount = byActor.Account | 126 | const byAccount = byActor.Account |
154 | 127 | ||