1 import { Transaction } from 'sequelize'
2 import { ActivityAnnounce, ActivityAudience } from '../../../../shared/models/activitypub'
3 import { ActorModel } from '../../../models/activitypub/actor'
4 import { VideoModel } from '../../../models/video/video'
5 import { VideoShareModel } from '../../../models/video/video-share'
6 import { broadcastToFollowers, getActorsInvolvedInVideo, getAudience, getObjectFollowersAudience } from './misc'
8 async function buildVideoAnnounceToFollowers (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) {
9 const announcedObject = video.url
11 const accountsToForwardView = await getActorsInvolvedInVideo(video, t)
12 const audience = getObjectFollowersAudience(accountsToForwardView)
13 return announceActivityData(videoShare.url, byActor, announcedObject, t, audience)
16 async function sendVideoAnnounceToFollowers (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) {
17 const data = await buildVideoAnnounceToFollowers(byActor, videoShare, video, t)
19 return broadcastToFollowers(data, byActor, [ byActor ], t)
22 async function announceActivityData (
27 audience?: ActivityAudience
28 ): Promise<ActivityAnnounce> {
30 audience = await getAudience(byActor, t)
43 // ---------------------------------------------------------------------------
46 sendVideoAnnounceToFollowers,
48 buildVideoAnnounceToFollowers