1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Continue activitypub

This commit is contained in:
Chocobozzz 2017-11-10 14:34:45 +01:00
parent e4f97babf7
commit 0d0e8dd090
No known key found for this signature in database
GPG key ID: 583A612D890159BE
27 changed files with 1039 additions and 1086 deletions

View file

@ -10,7 +10,8 @@ import {
VIDEO_CATEGORIES,
VIDEO_LICENCES,
VIDEO_LANGUAGES,
VIDEO_PRIVACIES
VIDEO_PRIVACIES,
VIDEO_MIMETYPE_EXT
} from '../../../initializers'
import {
addEventToRemoteVideo,
@ -50,6 +51,7 @@ import { abuseVideoRouter } from './abuse'
import { blacklistRouter } from './blacklist'
import { rateVideoRouter } from './rate'
import { videoChannelRouter } from './channel'
import { getActivityPubUrl } from '../../../helpers/activitypub'
const videosRouter = express.Router()
@ -59,19 +61,18 @@ const storage = multer.diskStorage({
cb(null, CONFIG.STORAGE.VIDEOS_DIR)
},
filename: (req, file, cb) => {
let extension = ''
if (file.mimetype === 'video/webm') extension = 'webm'
else if (file.mimetype === 'video/mp4') extension = 'mp4'
else if (file.mimetype === 'video/ogg') extension = 'ogv'
generateRandomString(16)
.then(randomString => {
cb(null, randomString + '.' + extension)
})
.catch(err => {
logger.error('Cannot generate random string for file name.', err)
throw err
})
filename: async (req, file, cb) => {
const extension = VIDEO_MIMETYPE_EXT[file.mimetype]
let randomString = ''
try {
randomString = await generateRandomString(16)
} catch (err) {
logger.error('Cannot generate random string for file name.', err)
randomString = 'fake-random-string'
}
cb(null, randomString + '.' + extension)
}
})
@ -190,6 +191,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi
channelId: res.locals.videoChannel.id
}
const video = db.Video.build(videoData)
video.url = getActivityPubUrl('video', video.uuid)
const videoFilePath = join(CONFIG.STORAGE.VIDEOS_DIR, videoPhysicalFile.filename)
const videoFileHeight = await getVideoFileHeight(videoFilePath)