]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/activitypub/share.ts
Add beautiful loading bar
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / share.ts
CommitLineData
892211e8
C
1import { Transaction } from 'sequelize'
2import { getServerAccount } from '../../helpers/utils'
3import { database as db } from '../../initializers'
4import { VideoChannelInstance } from '../../models/index'
5import { VideoInstance } from '../../models/video/video-interface'
4e50b6a1 6import { sendVideoAnnounceToFollowers, sendVideoChannelAnnounceToFollowers } from './send/send-announce'
892211e8
C
7
8async function shareVideoChannelByServer (videoChannel: VideoChannelInstance, t: Transaction) {
9 const serverAccount = await getServerAccount()
10
11 await db.VideoChannelShare.create({
12 accountId: serverAccount.id,
13 videoChannelId: videoChannel.id
14 }, { transaction: t })
15
4e50b6a1 16 return sendVideoChannelAnnounceToFollowers(serverAccount, videoChannel, t)
892211e8
C
17}
18
19async function shareVideoByServer (video: VideoInstance, t: Transaction) {
20 const serverAccount = await getServerAccount()
21
22 await db.VideoShare.create({
23 accountId: serverAccount.id,
24 videoId: video.id
25 }, { transaction: t })
26
4e50b6a1 27 return sendVideoAnnounceToFollowers(serverAccount, video, t)
892211e8
C
28}
29
30export {
31 shareVideoChannelByServer,
32 shareVideoByServer
33}