1 import { Transaction } from 'sequelize'
2 import { getServerAccount } from '../../helpers'
3 import { VideoModel } from '../../models/video/video'
4 import { VideoChannelModel } from '../../models/video/video-channel'
5 import { VideoChannelShareModel } from '../../models/video/video-channel-share'
6 import { VideoShareModel } from '../../models/video/video-share'
7 import { sendVideoAnnounceToFollowers, sendVideoChannelAnnounceToFollowers } from './send'
9 async function shareVideoChannelByServer (videoChannel: VideoChannelModel, t: Transaction) {
10 const serverAccount = await getServerAccount()
12 await VideoChannelShareModel.create({
13 accountId: serverAccount.id,
14 videoChannelId: videoChannel.id
15 }, { transaction: t })
17 return sendVideoChannelAnnounceToFollowers(serverAccount, videoChannel, t)
20 async function shareVideoByServer (video: VideoModel, t: Transaction) {
21 const serverAccount = await getServerAccount()
23 await VideoShareModel.create({
24 accountId: serverAccount.id,
26 }, { transaction: t })
28 return sendVideoAnnounceToFollowers(serverAccount, video, t)
32 shareVideoChannelByServer,