]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/activitypub/share.ts
Save
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / share.ts
CommitLineData
892211e8 1import { Transaction } from 'sequelize'
3fd3ab2d
C
2import { getServerAccount } from '../../helpers'
3import { VideoModel } from '../../models/video/video'
4import { VideoChannelModel } from '../../models/video/video-channel'
5import { VideoChannelShareModel } from '../../models/video/video-channel-share'
6import { VideoShareModel } from '../../models/video/video-share'
7import { sendVideoAnnounceToFollowers, sendVideoChannelAnnounceToFollowers } from './send'
892211e8 8
3fd3ab2d 9async function shareVideoChannelByServer (videoChannel: VideoChannelModel, t: Transaction) {
892211e8
C
10 const serverAccount = await getServerAccount()
11
3fd3ab2d 12 await VideoChannelShareModel.create({
892211e8
C
13 accountId: serverAccount.id,
14 videoChannelId: videoChannel.id
15 }, { transaction: t })
16
4e50b6a1 17 return sendVideoChannelAnnounceToFollowers(serverAccount, videoChannel, t)
892211e8
C
18}
19
3fd3ab2d 20async function shareVideoByServer (video: VideoModel, t: Transaction) {
892211e8
C
21 const serverAccount = await getServerAccount()
22
3fd3ab2d 23 await VideoShareModel.create({
892211e8
C
24 accountId: serverAccount.id,
25 videoId: video.id
26 }, { transaction: t })
27
4e50b6a1 28 return sendVideoAnnounceToFollowers(serverAccount, video, t)
892211e8
C
29}
30
31export {
32 shareVideoChannelByServer,
33 shareVideoByServer
34}