+import { addVideoComments } from './video-comments'
+import { crawlCollectionPage } from './crawl'
+import { sendCreateVideo, sendUpdateVideo } from './send'
+import { shareVideoByServerAndChannel } from './index'
+import { isArray } from '../../helpers/custom-validators/misc'
+import { VideoCaptionModel } from '../../models/video/video-caption'
+
+async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) {
+ // If the video is not private and published, we federate it
+ if (video.privacy !== VideoPrivacy.PRIVATE && video.state === VideoState.PUBLISHED) {
+ // Fetch more attributes that we will need to serialize in AP object
+ if (isArray(video.VideoCaptions) === false) {
+ video.VideoCaptions = await video.$get('VideoCaptions', {
+ attributes: [ 'language' ],
+ transaction
+ }) as VideoCaptionModel[]
+ }