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:
parent
0d0e8dd090
commit
38fa206583
34 changed files with 111 additions and 1367 deletions
|
@ -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'
|
||||
|
|
45
server/helpers/custom-validators/video-accounts.ts
Normal file
45
server/helpers/custom-validators/video-accounts.ts
Normal 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
|
||||
}
|
|
@ -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 => {
|
||||
|
|
|
@ -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 => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue