]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/lib/activitypub/share.ts
Unfollow with host
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / share.ts
... / ...
CommitLineData
1import { Transaction } from 'sequelize'
2import { getServerActor } from '../../helpers'
3import { VideoModel } from '../../models/video/video'
4import { VideoShareModel } from '../../models/video/video-share'
5import { sendVideoAnnounceToFollowers } from './send'
6
7async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) {
8 const serverActor = await getServerActor()
9
10 const serverShare = VideoShareModel.create({
11 actorId: serverActor.id,
12 videoId: video.id
13 }, { transaction: t })
14
15 const videoChannelShare = VideoShareModel.create({
16 actorId: video.VideoChannel.actorId,
17 videoId: video.id
18 }, { transaction: t })
19
20 await Promise.all([
21 serverShare,
22 videoChannelShare
23 ])
24
25 return sendVideoAnnounceToFollowers(serverActor, video, t)
26}
27
28export {
29 shareVideoByServerAndChannel
30}