aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/process/process-update.ts2
-rw-r--r--server/lib/activitypub/videos.ts21
-rw-r--r--server/lib/job-queue/handlers/activitypub-refresher.ts3
3 files changed, 16 insertions, 10 deletions
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index 03831a00e..c6b42d846 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -51,7 +51,7 @@ async function processUpdateVideo (actor: ActorModel, activity: ActivityUpdate)
51 return undefined 51 return undefined
52 } 52 }
53 53
54 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoObject.id }) 54 const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoObject.id, allowRefresh: false })
55 const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject) 55 const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject)
56 56
57 const updateOptions = { 57 const updateOptions = {
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index 998f90330..a5d649391 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -158,25 +158,30 @@ async function syncVideoExternalAttributes (video: VideoModel, fetchedVideo: Vid
158async function getOrCreateVideoAndAccountAndChannel (options: { 158async function getOrCreateVideoAndAccountAndChannel (options: {
159 videoObject: VideoTorrentObject | string, 159 videoObject: VideoTorrentObject | string,
160 syncParam?: SyncParam, 160 syncParam?: SyncParam,
161 fetchType?: VideoFetchByUrlType 161 fetchType?: VideoFetchByUrlType,
162 allowRefresh?: boolean // true by default
162}) { 163}) {
163 // Default params 164 // Default params
164 const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false } 165 const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false }
165 const fetchType = options.fetchType || 'all' 166 const fetchType = options.fetchType || 'all'
167 const allowRefresh = options.allowRefresh !== false
166 168
167 // Get video url 169 // Get video url
168 const videoUrl = getAPUrl(options.videoObject) 170 const videoUrl = getAPUrl(options.videoObject)
169 171
170 let videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType) 172 let videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType)
171 if (videoFromDatabase) { 173 if (videoFromDatabase) {
172 const refreshOptions = {
173 video: videoFromDatabase,
174 fetchedType: fetchType,
175 syncParam
176 }
177 174
178 if (syncParam.refreshVideo === true) videoFromDatabase = await refreshVideoIfNeeded(refreshOptions) 175 if (allowRefresh === true) {
179 else await JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', videoUrl: videoFromDatabase.url } }) 176 const refreshOptions = {
177 video: videoFromDatabase,
178 fetchedType: fetchType,
179 syncParam
180 }
181
182 if (syncParam.refreshVideo === true) videoFromDatabase = await refreshVideoIfNeeded(refreshOptions)
183 else await JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', videoUrl: videoFromDatabase.url } })
184 }
180 185
181 return { video: videoFromDatabase } 186 return { video: videoFromDatabase }
182 } 187 }
diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/lib/job-queue/handlers/activitypub-refresher.ts
index 7752b3b40..671b0f487 100644
--- a/server/lib/job-queue/handlers/activitypub-refresher.ts
+++ b/server/lib/job-queue/handlers/activitypub-refresher.ts
@@ -10,7 +10,8 @@ export type RefreshPayload = {
10 10
11async function refreshAPObject (job: Bull.Job) { 11async function refreshAPObject (job: Bull.Job) {
12 const payload = job.data as RefreshPayload 12 const payload = job.data as RefreshPayload
13 logger.info('Processing AP refresher in job %d.', job.id) 13
14 logger.info('Processing AP refresher in job %d for video %s.', job.id, payload.videoUrl)
14 15
15 if (payload.type === 'video') return refreshAPVideo(payload.videoUrl) 16 if (payload.type === 'video') return refreshAPVideo(payload.videoUrl)
16} 17}