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

Add video privacy setting

This commit is contained in:
Chocobozzz 2017-10-31 11:52:52 +01:00
parent b7a485121d
commit fd45e8f43c
No known key found for this signature in database
GPG key ID: 583A612D890159BE
48 changed files with 545 additions and 208 deletions

View file

@ -30,6 +30,8 @@ import {
} from '../../../shared'
import { createUserAuthorAndChannel } from '../../lib'
import { UserInstance } from '../../models'
import { videosSortValidator } from '../../middlewares/validators/sort'
import { setVideosSort } from '../../middlewares/sort'
const usersRouter = express.Router()
@ -38,6 +40,15 @@ usersRouter.get('/me',
asyncMiddleware(getUserInformation)
)
usersRouter.get('/me/videos',
authenticate,
paginationValidator,
videosSortValidator,
setVideosSort,
setPagination,
asyncMiddleware(getUserVideos)
)
usersRouter.get('/me/videos/:videoId/rating',
authenticate,
usersVideoRatingValidator,
@ -101,6 +112,13 @@ export {
// ---------------------------------------------------------------------------
async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
const user = res.locals.oauth.token.User
const resultList = await db.Video.listUserVideosForApi(user.id ,req.query.start, req.query.count, req.query.sort)
return res.json(getFormattedObjects(resultList.data, resultList.total))
}
async function createUserRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) {
const options = {
arguments: [ req, res ],
@ -146,13 +164,14 @@ async function registerUser (req: express.Request, res: express.Response, next:
}
async function getUserInformation (req: express.Request, res: express.Response, next: express.NextFunction) {
// We did not load channels in res.locals.user
const user = await db.User.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
return res.json(user.toFormattedJSON())
}
function getUser (req: express.Request, res: express.Response, next: express.NextFunction) {
return res.json(res.locals.user.toFormattedJSON())
return res.json(res.locals.oauth.token.User.toFormattedJSON())
}
async function getUserVideoRating (req: express.Request, res: express.Response, next: express.NextFunction) {