]>
Commit | Line | Data |
---|---|---|
892211e8 | 1 | import { Transaction } from 'sequelize' |
e12a0092 | 2 | import { VideoPrivacy } from '../../../shared/models/videos' |
50d6de9c | 3 | import { getServerActor } from '../../helpers' |
3fd3ab2d | 4 | import { VideoModel } from '../../models/video/video' |
3fd3ab2d | 5 | import { VideoShareModel } from '../../models/video/video-share' |
50d6de9c | 6 | import { sendVideoAnnounceToFollowers } from './send' |
892211e8 | 7 | |
a7d647c4 | 8 | async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) { |
e12a0092 C |
9 | if (video.privacy === VideoPrivacy.PRIVATE) return |
10 | ||
50d6de9c | 11 | const serverActor = await getServerActor() |
892211e8 | 12 | |
a7d647c4 | 13 | const serverShare = VideoShareModel.create({ |
50d6de9c | 14 | actorId: serverActor.id, |
892211e8 C |
15 | videoId: video.id |
16 | }, { transaction: t }) | |
17 | ||
a7d647c4 C |
18 | const videoChannelShare = VideoShareModel.create({ |
19 | actorId: video.VideoChannel.actorId, | |
20 | videoId: video.id | |
21 | }, { transaction: t }) | |
22 | ||
23 | await Promise.all([ | |
24 | serverShare, | |
25 | videoChannelShare | |
26 | ]) | |
27 | ||
50d6de9c | 28 | return sendVideoAnnounceToFollowers(serverActor, video, t) |
892211e8 C |
29 | } |
30 | ||
31 | export { | |
a7d647c4 | 32 | shareVideoByServerAndChannel |
892211e8 | 33 | } |