+async function sendCreateVideoPlaylist (playlist: MVideoPlaylistFull, t: Transaction) {
+ if (playlist.privacy === VideoPlaylistPrivacy.PRIVATE) return undefined
+
+ logger.info('Creating job to send create video playlist of %s.', playlist.url, lTags(playlist.uuid))
+
+ 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: MCommentOwnerVideo, t: Transaction) {
+ logger.info('Creating job to send comment %s.', comment.url)
+
+ const isOrigin = comment.Video.isOwned()
+
+ const byActor = comment.Account.Actor
+ const threadParentComments = await VideoCommentModel.listThreadParentComments(comment, t)
+ const commentObject = comment.toActivityPubObject(threadParentComments)
+
+ const actorsInvolvedInComment = await getActorsInvolvedInVideo(comment.Video, t)
+ // Add the actor that commented too
+ actorsInvolvedInComment.push(byActor)
+
+ const parentsCommentActors = threadParentComments.filter(c => !c.isDeleted())
+ .map(c => c.Account.Actor)
+
+ let audience: ActivityAudience
+ if (isOrigin) {
+ audience = getVideoCommentAudience(comment, threadParentComments, actorsInvolvedInComment, isOrigin)
+ } else {
+ audience = getAudienceFromFollowersOf(actorsInvolvedInComment.concat(parentsCommentActors))