1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Move activitypub functions from helpers/ to lib/

This commit is contained in:
Chocobozzz 2017-11-20 10:24:29 +01:00
parent 5414139835
commit 892211e849
No known key found for this signature in database
GPG key ID: 583A612D890159BE
26 changed files with 341 additions and 305 deletions

View file

@ -0,0 +1,33 @@
import { Transaction } from 'sequelize'
import { getServerAccount } from '../../helpers/utils'
import { database as db } from '../../initializers'
import { VideoChannelInstance } from '../../models/index'
import { VideoInstance } from '../../models/video/video-interface'
import { sendVideoAnnounce, sendVideoChannelAnnounce } from './send/send-announce'
async function shareVideoChannelByServer (videoChannel: VideoChannelInstance, t: Transaction) {
const serverAccount = await getServerAccount()
await db.VideoChannelShare.create({
accountId: serverAccount.id,
videoChannelId: videoChannel.id
}, { transaction: t })
return sendVideoChannelAnnounce(serverAccount, videoChannel, t)
}
async function shareVideoByServer (video: VideoInstance, t: Transaction) {
const serverAccount = await getServerAccount()
await db.VideoShare.create({
accountId: serverAccount.id,
videoId: video.id
}, { transaction: t })
return sendVideoAnnounce(serverAccount, video, t)
}
export {
shareVideoChannelByServer,
shareVideoByServer
}