PeerTube/server/lib/activitypub/share.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

import { Transaction } from 'sequelize'
2017-12-12 17:53:50 +01:00
import { getServerAccount } from '../../helpers'
import { VideoModel } from '../../models/video/video'
import { VideoChannelModel } from '../../models/video/video-channel'
import { VideoChannelShareModel } from '../../models/video/video-channel-share'
import { VideoShareModel } from '../../models/video/video-share'
import { sendVideoAnnounceToFollowers, sendVideoChannelAnnounceToFollowers } from './send'
2017-12-12 17:53:50 +01:00
async function shareVideoChannelByServer (videoChannel: VideoChannelModel, t: Transaction) {
const serverAccount = await getServerAccount()
2017-12-12 17:53:50 +01:00
await VideoChannelShareModel.create({
accountId: serverAccount.id,
videoChannelId: videoChannel.id
}, { transaction: t })
return sendVideoChannelAnnounceToFollowers(serverAccount, videoChannel, t)
}
2017-12-12 17:53:50 +01:00
async function shareVideoByServer (video: VideoModel, t: Transaction) {
const serverAccount = await getServerAccount()
2017-12-12 17:53:50 +01:00
await VideoShareModel.create({
accountId: serverAccount.id,
videoId: video.id
}, { transaction: t })
return sendVideoAnnounceToFollowers(serverAccount, video, t)
}
export {
shareVideoChannelByServer,
shareVideoByServer
}