]>
Commit | Line | Data |
---|---|---|
892211e8 | 1 | import { Transaction } from 'sequelize' |
50d6de9c | 2 | import { getServerActor } from '../../helpers' |
3fd3ab2d | 3 | import { VideoModel } from '../../models/video/video' |
3fd3ab2d | 4 | import { VideoShareModel } from '../../models/video/video-share' |
50d6de9c | 5 | import { sendVideoAnnounceToFollowers } from './send' |
892211e8 | 6 | |
a7d647c4 | 7 | async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) { |
50d6de9c | 8 | const serverActor = await getServerActor() |
892211e8 | 9 | |
a7d647c4 | 10 | const serverShare = VideoShareModel.create({ |
50d6de9c | 11 | actorId: serverActor.id, |
892211e8 C |
12 | videoId: video.id |
13 | }, { transaction: t }) | |
14 | ||
a7d647c4 C |
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 | ||
50d6de9c | 25 | return sendVideoAnnounceToFollowers(serverActor, video, t) |
892211e8 C |
26 | } |
27 | ||
28 | export { | |
a7d647c4 | 29 | shareVideoByServerAndChannel |
892211e8 | 30 | } |