mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Basic video redundancy implementation
This commit is contained in:
parent
a651038487
commit
c48e82b5e0
77 changed files with 1667 additions and 287 deletions
|
@ -4,45 +4,44 @@ import { ActorModel } from '../../../models/activitypub/actor'
|
|||
import { VideoModel } from '../../../models/video/video'
|
||||
import { VideoShareModel } from '../../../models/video/video-share'
|
||||
import { broadcastToFollowers } from './utils'
|
||||
import { getActorsInvolvedInVideo, getAudience, getObjectFollowersAudience } from '../audience'
|
||||
import { audiencify, getActorsInvolvedInVideo, getAudience, getObjectFollowersAudience } from '../audience'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
|
||||
async function buildVideoAnnounce (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) {
|
||||
async function buildAnnounceWithVideoAudience (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) {
|
||||
const announcedObject = video.url
|
||||
|
||||
const accountsToForwardView = await getActorsInvolvedInVideo(video, t)
|
||||
const audience = getObjectFollowersAudience(accountsToForwardView)
|
||||
return announceActivityData(videoShare.url, byActor, announcedObject, audience)
|
||||
const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t)
|
||||
const audience = getObjectFollowersAudience(actorsInvolvedInVideo)
|
||||
|
||||
const activity = buildAnnounceActivity(videoShare.url, byActor, announcedObject, audience)
|
||||
|
||||
return { activity, actorsInvolvedInVideo }
|
||||
}
|
||||
|
||||
async function sendVideoAnnounce (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) {
|
||||
const data = await buildVideoAnnounce(byActor, videoShare, video, t)
|
||||
const { activity, actorsInvolvedInVideo } = await buildAnnounceWithVideoAudience(byActor, videoShare, video, t)
|
||||
|
||||
logger.info('Creating job to send announce %s.', videoShare.url)
|
||||
|
||||
const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t)
|
||||
const followersException = [ byActor ]
|
||||
|
||||
return broadcastToFollowers(data, byActor, actorsInvolvedInVideo, t, followersException)
|
||||
return broadcastToFollowers(activity, byActor, actorsInvolvedInVideo, t, followersException)
|
||||
}
|
||||
|
||||
function announceActivityData (url: string, byActor: ActorModel, object: string, audience?: ActivityAudience): ActivityAnnounce {
|
||||
function buildAnnounceActivity (url: string, byActor: ActorModel, object: string, audience?: ActivityAudience): ActivityAnnounce {
|
||||
if (!audience) audience = getAudience(byActor)
|
||||
|
||||
return {
|
||||
type: 'Announce',
|
||||
to: audience.to,
|
||||
cc: audience.cc,
|
||||
return audiencify({
|
||||
type: 'Announce' as 'Announce',
|
||||
id: url,
|
||||
actor: byActor.url,
|
||||
object
|
||||
}
|
||||
}, audience)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
sendVideoAnnounce,
|
||||
announceActivityData,
|
||||
buildVideoAnnounce
|
||||
buildAnnounceActivity,
|
||||
buildAnnounceWithVideoAudience
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue