1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Add shares forward and collection on videos/video channels

This commit is contained in:
Chocobozzz 2017-11-27 14:44:51 +01:00
parent 74bb2cb834
commit 4e50b6a1c9
No known key found for this signature in database
GPG key ID: 583A612D890159BE
29 changed files with 546 additions and 133 deletions

View file

@ -1,14 +1,14 @@
import * as Promise from 'bluebird'
import * as validator from 'validator'
import * as Bluebird from 'bluebird'
import * as express from 'express'
import 'express-validator'
import 'multer'
import * as validator from 'validator'
import { database as db, CONSTRAINTS_FIELDS } from '../../initializers'
import { CONSTRAINTS_FIELDS, database as db } from '../../initializers'
import { VideoChannelInstance } from '../../models'
import { logger } from '../logger'
import { exists } from './misc'
import { isActivityPubUrlValid } from './index'
import { exists } from './misc'
const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_CHANNELS
@ -25,7 +25,7 @@ function isVideoChannelNameValid (value: string) {
}
function checkVideoChannelExists (id: string, res: express.Response, callback: () => void) {
let promise: Promise<VideoChannelInstance>
let promise: Bluebird<VideoChannelInstance>
if (validator.isInt(id)) {
promise = db.VideoChannel.loadAndPopulateAccount(+id)
} else { // UUID
@ -48,11 +48,32 @@ function checkVideoChannelExists (id: string, res: express.Response, callback: (
})
}
async function isVideoChannelExistsPromise (id: string, res: express.Response) {
let videoChannel: VideoChannelInstance
if (validator.isInt(id)) {
videoChannel = await db.VideoChannel.loadAndPopulateAccount(+id)
} else { // UUID
videoChannel = await db.VideoChannel.loadByUUIDAndPopulateAccount(id)
}
if (!videoChannel) {
res.status(404)
.json({ error: 'Video channel not found' })
.end()
return false
}
res.locals.videoChannel = videoChannel
return true
}
// ---------------------------------------------------------------------------
export {
isVideoChannelDescriptionValid,
isVideoChannelNameValid,
checkVideoChannelExists,
isVideoChannelNameValid,
isVideoChannelExistsPromise,
isVideoChannelUrlValid
}