]>
Commit | Line | Data |
---|---|---|
892211e8 | 1 | import { Transaction } from 'sequelize' |
3fd3ab2d C |
2 | import { getServerAccount } from '../../helpers' |
3 | import { VideoModel } from '../../models/video/video' | |
4 | import { VideoChannelModel } from '../../models/video/video-channel' | |
5 | import { VideoChannelShareModel } from '../../models/video/video-channel-share' | |
6 | import { VideoShareModel } from '../../models/video/video-share' | |
7 | import { sendVideoAnnounceToFollowers, sendVideoChannelAnnounceToFollowers } from './send' | |
892211e8 | 8 | |
3fd3ab2d | 9 | async 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 | 20 | async 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 | ||
31 | export { | |
32 | shareVideoChannelByServer, | |
33 | shareVideoByServer | |
34 | } |