aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-12-04 15:12:54 +0100
committerChocobozzz <me@florianbigard.com>2018-12-04 16:04:14 +0100
commit745778256ced65415b04a9817fc49db70d4b6681 (patch)
tree184a3cd6c7d24ba94c5aa282b52a162a3b95d21c /server/lib/activitypub/videos.ts
parent2beb98952a4c5939f33ea2dc77f0bd053bffbb5a (diff)
downloadPeerTube-745778256ced65415b04a9817fc49db70d4b6681.tar.gz
PeerTube-745778256ced65415b04a9817fc49db70d4b6681.tar.zst
PeerTube-745778256ced65415b04a9817fc49db70d4b6681.zip
Fix thumbnail processing
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r--server/lib/activitypub/videos.ts21
1 files changed, 13 insertions, 8 deletions
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 }