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:
parent
5414139835
commit
892211e849
26 changed files with 341 additions and 305 deletions
33
server/lib/activitypub/share.ts
Normal file
33
server/lib/activitypub/share.ts
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue