diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-20 10:24:29 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 892211e8493b1f992fce7616cb1e48b7ff87a1dc (patch) | |
tree | 7bb218141a20c14d293d695ad4dad12687e537b2 /server/lib/activitypub/share.ts | |
parent | 54141398354e6e7b94aa3065a705a1251390111c (diff) | |
download | PeerTube-892211e8493b1f992fce7616cb1e48b7ff87a1dc.tar.gz PeerTube-892211e8493b1f992fce7616cb1e48b7ff87a1dc.tar.zst PeerTube-892211e8493b1f992fce7616cb1e48b7ff87a1dc.zip |
Move activitypub functions from helpers/ to lib/
Diffstat (limited to 'server/lib/activitypub/share.ts')
-rw-r--r-- | server/lib/activitypub/share.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts new file mode 100644 index 000000000..689e200a6 --- /dev/null +++ b/server/lib/activitypub/share.ts | |||
@@ -0,0 +1,33 @@ | |||
1 | import { Transaction } from 'sequelize' | ||
2 | import { getServerAccount } from '../../helpers/utils' | ||
3 | import { database as db } from '../../initializers' | ||
4 | import { VideoChannelInstance } from '../../models/index' | ||
5 | import { VideoInstance } from '../../models/video/video-interface' | ||
6 | import { sendVideoAnnounce, sendVideoChannelAnnounce } from './send/send-announce' | ||
7 | |||
8 | async 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 | |||
16 | return sendVideoChannelAnnounce(serverAccount, videoChannel, t) | ||
17 | } | ||
18 | |||
19 | async 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 | |||
27 | return sendVideoAnnounce(serverAccount, video, t) | ||
28 | } | ||
29 | |||
30 | export { | ||
31 | shareVideoChannelByServer, | ||
32 | shareVideoByServer | ||
33 | } | ||