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

Remove references to author

This commit is contained in:
Chocobozzz 2017-11-10 14:48:08 +01:00
parent 0d0e8dd090
commit 38fa206583
No known key found for this signature in database
GPG key ID: 583A612D890159BE
34 changed files with 111 additions and 1367 deletions

View file

@ -3,5 +3,6 @@ export * from './misc'
export * from './pods'
export * from './pods'
export * from './users'
export * from './video-accounts'
export * from './video-channels'
export * from './videos'

View file

@ -0,0 +1,45 @@
import * as Promise from 'bluebird'
import * as validator from 'validator'
import * as express from 'express'
import 'express-validator'
import { database as db } from '../../initializers'
import { AccountInstance } from '../../models'
import { logger } from '../logger'
import { isUserUsernameValid } from './users'
function isVideoAccountNameValid (value: string) {
return isUserUsernameValid(value)
}
function checkVideoAccountExists (id: string, res: express.Response, callback: () => void) {
let promise: Promise<AccountInstance>
if (validator.isInt(id)) {
promise = db.Account.load(+id)
} else { // UUID
promise = db.Account.loadByUUID(id)
}
promise.then(account => {
if (!account) {
return res.status(404)
.json({ error: 'Video account not found' })
.end()
}
res.locals.account = account
callback()
})
.catch(err => {
logger.error('Error in video account request validator.', err)
return res.sendStatus(500)
})
}
// ---------------------------------------------------------------------------
export {
checkVideoAccountExists,
isVideoAccountNameValid
}

View file

@ -26,9 +26,9 @@ function isVideoChannelUUIDValid (value: string) {
function checkVideoChannelExists (id: string, res: express.Response, callback: () => void) {
let promise: Promise<VideoChannelInstance>
if (validator.isInt(id)) {
promise = db.VideoChannel.loadAndPopulateAuthor(+id)
promise = db.VideoChannel.loadAndPopulateAccount(+id)
} else { // UUID
promise = db.VideoChannel.loadByUUIDAndPopulateAuthor(id)
promise = db.VideoChannel.loadByUUIDAndPopulateAccount(id)
}
promise.then(videoChannel => {

View file

@ -166,9 +166,9 @@ function isVideoFileInfoHashValid (value: string) {
function checkVideoExists (id: string, res: express.Response, callback: () => void) {
let promise: Promise<VideoInstance>
if (validator.isInt(id)) {
promise = db.Video.loadAndPopulateAuthorAndPodAndTags(+id)
promise = db.Video.loadAndPopulateAccountAndPodAndTags(+id)
} else { // UUID
promise = db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(id)
promise = db.Video.loadByUUIDAndPopulateAccountAndPodAndTags(id)
}
promise.then(video => {