diff options
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r-- | server/lib/activitypub/videos.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 379c2a0d7..5794988a5 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -29,6 +29,7 @@ import { addVideoShares, shareVideoByServerAndChannel } from './share' | |||
29 | import { AccountModel } from '../../models/account/account' | 29 | import { AccountModel } from '../../models/account/account' |
30 | import { fetchVideoByUrl, VideoFetchByUrlType } from '../../helpers/video' | 30 | import { fetchVideoByUrl, VideoFetchByUrlType } from '../../helpers/video' |
31 | import { checkUrlsSameHost, getAPUrl } from '../../helpers/activitypub' | 31 | import { checkUrlsSameHost, getAPUrl } from '../../helpers/activitypub' |
32 | import { Notifier } from '../notifier' | ||
32 | 33 | ||
33 | async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { | 34 | async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { |
34 | // If the video is not private and published, we federate it | 35 | // If the video is not private and published, we federate it |
@@ -181,7 +182,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: { | |||
181 | else await JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', videoUrl: videoFromDatabase.url } }) | 182 | else await JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', videoUrl: videoFromDatabase.url } }) |
182 | } | 183 | } |
183 | 184 | ||
184 | return { video: videoFromDatabase } | 185 | return { video: videoFromDatabase, created: false } |
185 | } | 186 | } |
186 | 187 | ||
187 | const { videoObject: fetchedVideo } = await fetchRemoteVideo(videoUrl) | 188 | const { videoObject: fetchedVideo } = await fetchRemoteVideo(videoUrl) |
@@ -192,7 +193,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: { | |||
192 | 193 | ||
193 | await syncVideoExternalAttributes(video, fetchedVideo, syncParam) | 194 | await syncVideoExternalAttributes(video, fetchedVideo, syncParam) |
194 | 195 | ||
195 | return { video } | 196 | return { video, created: true } |
196 | } | 197 | } |
197 | 198 | ||
198 | async function updateVideoFromAP (options: { | 199 | async function updateVideoFromAP (options: { |
@@ -213,6 +214,9 @@ async function updateVideoFromAP (options: { | |||
213 | 214 | ||
214 | videoFieldsSave = options.video.toJSON() | 215 | videoFieldsSave = options.video.toJSON() |
215 | 216 | ||
217 | const wasPrivateVideo = options.video.privacy === VideoPrivacy.PRIVATE | ||
218 | const wasUnlistedVideo = options.video.privacy === VideoPrivacy.UNLISTED | ||
219 | |||
216 | // Check actor has the right to update the video | 220 | // Check actor has the right to update the video |
217 | const videoChannel = options.video.VideoChannel | 221 | const videoChannel = options.video.VideoChannel |
218 | if (videoChannel.Account.id !== options.account.id) { | 222 | if (videoChannel.Account.id !== options.account.id) { |
@@ -277,6 +281,13 @@ async function updateVideoFromAP (options: { | |||
277 | }) | 281 | }) |
278 | options.video.VideoCaptions = await Promise.all(videoCaptionsPromises) | 282 | options.video.VideoCaptions = await Promise.all(videoCaptionsPromises) |
279 | } | 283 | } |
284 | |||
285 | { | ||
286 | // Notify our users? | ||
287 | if (wasPrivateVideo || wasUnlistedVideo) { | ||
288 | Notifier.Instance.notifyOnNewVideo(options.video) | ||
289 | } | ||
290 | } | ||
280 | }) | 291 | }) |
281 | 292 | ||
282 | logger.info('Remote video with uuid %s updated', options.videoObject.uuid) | 293 | logger.info('Remote video with uuid %s updated', options.videoObject.uuid) |