mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Send server announce when users upload a video
This commit is contained in:
parent
d846501818
commit
efc32059d9
22 changed files with 161 additions and 80 deletions
|
@ -2,7 +2,7 @@ import * as express from 'express'
|
|||
import { UserRight } from '../../../../shared/models/users/user-right.enum'
|
||||
import { getFormattedObjects } from '../../../helpers'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { getApplicationAccount } from '../../../helpers/utils'
|
||||
import { getServerAccount } from '../../../helpers/utils'
|
||||
import { getAccountFromWebfinger } from '../../../helpers/webfinger'
|
||||
import { SERVER_ACCOUNT_NAME } from '../../../initializers/constants'
|
||||
import { database as db } from '../../../initializers/database'
|
||||
|
@ -50,14 +50,14 @@ export {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const applicationAccount = await getApplicationAccount()
|
||||
const applicationAccount = await getServerAccount()
|
||||
const resultList = await db.AccountFollow.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
|
||||
|
||||
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||
}
|
||||
|
||||
async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const applicationAccount = await getApplicationAccount()
|
||||
const applicationAccount = await getServerAccount()
|
||||
const resultList = await db.AccountFollow.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
|
||||
|
||||
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||
|
@ -65,7 +65,7 @@ async function listFollowers (req: express.Request, res: express.Response, next:
|
|||
|
||||
async function follow (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const hosts = req.body.hosts as string[]
|
||||
const fromAccount = await getApplicationAccount()
|
||||
const fromAccount = await getServerAccount()
|
||||
|
||||
const tasks: Promise<any>[] = []
|
||||
const accountName = SERVER_ACCOUNT_NAME
|
||||
|
|
|
@ -12,10 +12,10 @@ import {
|
|||
resetSequelizeInstance,
|
||||
retryTransactionWrapper
|
||||
} from '../../../helpers'
|
||||
import { getActivityPubUrl } from '../../../helpers/activitypub'
|
||||
import { getActivityPubUrl, shareVideoByServer } from '../../../helpers/activitypub'
|
||||
import { CONFIG, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_MIMETYPE_EXT, VIDEO_PRIVACIES } from '../../../initializers'
|
||||
import { database as db } from '../../../initializers/database'
|
||||
import { sendAddVideo, sendUpdateVideoChannel } from '../../../lib/activitypub/send-request'
|
||||
import { sendAddVideo, sendUpdateVideo } from '../../../lib/activitypub/send-request'
|
||||
import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler'
|
||||
import {
|
||||
asyncMiddleware,
|
||||
|
@ -56,7 +56,7 @@ const storage = multer.diskStorage({
|
|||
randomString = 'fake-random-string'
|
||||
}
|
||||
|
||||
cb(null, randomString + '.' + extension)
|
||||
cb(null, randomString + extension)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -237,6 +237,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
|
|||
if (video.privacy === VideoPrivacy.PRIVATE) return undefined
|
||||
|
||||
await sendAddVideo(video, t)
|
||||
await shareVideoByServer(video, t)
|
||||
})
|
||||
|
||||
logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoUUID)
|
||||
|
@ -254,7 +255,7 @@ async function updateVideoRetryWrapper (req: express.Request, res: express.Respo
|
|||
}
|
||||
|
||||
async function updateVideo (req: express.Request, res: express.Response) {
|
||||
const videoInstance = res.locals.video
|
||||
const videoInstance: VideoInstance = res.locals.video
|
||||
const videoFieldsSave = videoInstance.toJSON()
|
||||
const videoInfoToUpdate: VideoUpdate = req.body
|
||||
const wasPrivateVideo = videoInstance.privacy === VideoPrivacy.PRIVATE
|
||||
|
@ -284,7 +285,7 @@ async function updateVideo (req: express.Request, res: express.Response) {
|
|||
|
||||
// Now we'll update the video's meta data to our friends
|
||||
if (wasPrivateVideo === false) {
|
||||
await sendUpdateVideoChannel(videoInstance, t)
|
||||
await sendUpdateVideo(videoInstance, t)
|
||||
}
|
||||
|
||||
// Video is not private anymore, send a create action to remote servers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue