import { audiencify, getActorsInvolvedInVideo, getAudience, getAudienceFromFollowersOf, getVideoCommentAudience } from '../audience'
import { logger } from '../../../helpers/logger'
import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy'
+import { VideoPlaylistModel } from '../../../models/video/video-playlist'
+import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
+import { getServerActor } from '../../../helpers/utils'
async function sendCreateVideo (video: VideoModel, t: Transaction) {
if (video.privacy === VideoPrivacy.PRIVATE) return undefined
return broadcastToFollowers(createActivity, byActor, [ byActor ], t)
}
-async function sendCreateCacheFile (byActor: ActorModel, fileRedundancy: VideoRedundancyModel) {
+async function sendCreateCacheFile (byActor: ActorModel, video: VideoModel, fileRedundancy: VideoRedundancyModel) {
logger.info('Creating job to send file cache of %s.', fileRedundancy.url)
- const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(fileRedundancy.VideoFile.Video.id)
- const redundancyObject = fileRedundancy.toActivityPubObject()
-
return sendVideoRelatedCreateActivity({
byActor,
video,
url: fileRedundancy.url,
- object: redundancyObject
+ object: fileRedundancy.toActivityPubObject()
})
}
+async function sendCreateVideoPlaylist (playlist: VideoPlaylistModel, t: Transaction) {
+ if (playlist.privacy === VideoPlaylistPrivacy.PRIVATE) return undefined
+
+ logger.info('Creating job to send create video playlist of %s.', playlist.url)
+
+ const byActor = playlist.OwnerAccount.Actor
+ const audience = getAudience(byActor, playlist.privacy === VideoPlaylistPrivacy.PUBLIC)
+
+ const object = await playlist.toActivityPubObject(null, t)
+ const createActivity = buildCreateActivity(playlist.url, byActor, object, audience)
+
+ const serverActor = await getServerActor()
+ const toFollowersOf = [ byActor, serverActor ]
+
+ if (playlist.VideoChannel) toFollowersOf.push(playlist.VideoChannel.Actor)
+
+ return broadcastToFollowers(createActivity, byActor, toFollowersOf, t)
+}
+
async function sendCreateVideoComment (comment: VideoCommentModel, t: Transaction) {
logger.info('Creating job to send comment %s.', comment.url)
sendCreateVideo,
buildCreateActivity,
sendCreateVideoComment,
+ sendCreateVideoPlaylist,
sendCreateCacheFile
}