import * as express from 'express'
import { getFormattedObjects, getServerActor } from '../../helpers/utils'
import {
- authenticate,
asyncMiddleware,
+ authenticate,
commonVideosFiltersValidator,
- videoRatingValidator,
optionalAuthenticate,
paginationValidator,
setDefaultPagination,
setDefaultSort,
videoPlaylistsSortValidator,
- videoRatesSortValidator
+ videoRatesSortValidator,
+ videoRatingValidator
} from '../../middlewares'
import {
accountNameWithHostGetValidator,
accountsSortValidator,
+ ensureAuthUserOwnsAccountValidator,
videosSortValidator,
- ensureAuthUserOwnsAccountValidator
+ videoChannelsSortValidator
} from '../../middlewares/validators'
import { AccountModel } from '../../models/account/account'
import { AccountVideoRateModel } from '../../models/account/account-video-rate'
accountsRouter.get('/:accountName/video-channels',
asyncMiddleware(accountNameWithHostGetValidator),
+ paginationValidator,
+ videoChannelsSortValidator,
+ setDefaultSort,
+ setDefaultPagination,
asyncMiddleware(listAccountChannels)
)
}
async function listAccountChannels (req: express.Request, res: express.Response) {
- const resultList = await VideoChannelModel.listByAccount(res.locals.account.id)
+ const options = {
+ accountId: res.locals.account.id,
+ start: req.query.start,
+ count: req.query.count,
+ sort: req.query.sort
+ }
+
+ const resultList = await VideoChannelModel.listByAccount(options)
return res.json(getFormattedObjects(resultList.data, resultList.total))
}