1 import { Transaction } from 'sequelize'
2 import { VideoPrivacy } from '../../../shared/models/videos'
3 import { getServerActor } from '../../helpers/utils'
4 import { VideoModel } from '../../models/video/video'
5 import { VideoShareModel } from '../../models/video/video-share'
6 import { sendVideoAnnounceToFollowers } from './send'
8 async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) {
9 if (video.privacy === VideoPrivacy.PRIVATE) return undefined
11 const serverActor = await getServerActor()
13 const serverShare = VideoShareModel.create({
14 actorId: serverActor.id,
16 }, { transaction: t })
18 const videoChannelShare = VideoShareModel.create({
19 actorId: video.VideoChannel.actorId,
21 }, { transaction: t })
28 return sendVideoAnnounceToFollowers(serverActor, video, t)
32 shareVideoByServerAndChannel