diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/process/process-update.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/videos.ts | 21 |
2 files changed, 14 insertions, 9 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 | |||
158 | async function getOrCreateVideoAndAccountAndChannel (options: { | 158 | async 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 | } |