1 import { Transaction } from 'sequelize'
2 import { getServerAccount } from '../../helpers/utils'
3 import { database as db } from '../../initializers'
4 import { VideoChannelInstance } from '../../models/index'
5 import { VideoInstance } from '../../models/video/video-interface'
6 import { sendVideoAnnounce, sendVideoChannelAnnounce } from './send/send-announce'
8 async function shareVideoChannelByServer (videoChannel: VideoChannelInstance, t: Transaction) {
9 const serverAccount = await getServerAccount()
11 await db.VideoChannelShare.create({
12 accountId: serverAccount.id,
13 videoChannelId: videoChannel.id
14 }, { transaction: t })
16 return sendVideoChannelAnnounce(serverAccount, videoChannel, t)
19 async function shareVideoByServer (video: VideoInstance, t: Transaction) {
20 const serverAccount = await getServerAccount()
22 await db.VideoShare.create({
23 accountId: serverAccount.id,
25 }, { transaction: t })
27 return sendVideoAnnounce(serverAccount, video, t)
31 shareVideoChannelByServer,