mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 09:49:20 +02:00
Add channel collaborators feature
This commit is contained in:
parent
94e55dfc6c
commit
135d5c7363
185 changed files with 5457 additions and 2631 deletions
|
@ -56,10 +56,10 @@ const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_
|
|||
|
||||
const meRouter = express.Router()
|
||||
|
||||
meRouter.get('/me', authenticate, asyncMiddleware(getUserInformation))
|
||||
meRouter.get('/me', authenticate, asyncMiddleware(getMyInformation))
|
||||
meRouter.delete('/me', authenticate, deleteMeValidator, asyncMiddleware(deleteMe))
|
||||
|
||||
meRouter.get('/me/video-quota-used', authenticate, asyncMiddleware(getUserVideoQuotaUsed))
|
||||
meRouter.get('/me/video-quota-used', authenticate, asyncMiddleware(getMyVideoQuotaUsed))
|
||||
|
||||
meRouter.get(
|
||||
'/me/videos/imports',
|
||||
|
@ -69,7 +69,7 @@ meRouter.get(
|
|||
setDefaultSort,
|
||||
setDefaultPagination,
|
||||
getMyVideoImportsValidator,
|
||||
asyncMiddleware(getUserVideoImports)
|
||||
asyncMiddleware(listMyVideoImports)
|
||||
)
|
||||
|
||||
meRouter.get(
|
||||
|
@ -92,14 +92,14 @@ meRouter.get(
|
|||
setDefaultPagination,
|
||||
commonVideosFiltersValidator,
|
||||
asyncMiddleware(usersVideosValidator),
|
||||
asyncMiddleware(listUserVideos)
|
||||
asyncMiddleware(listMyVideos)
|
||||
)
|
||||
|
||||
meRouter.get(
|
||||
'/me/videos/:videoId/rating',
|
||||
authenticate,
|
||||
asyncMiddleware(usersVideoRatingValidator),
|
||||
asyncMiddleware(getUserVideoRating)
|
||||
asyncMiddleware(getMyVideoRating)
|
||||
)
|
||||
|
||||
meRouter.put(
|
||||
|
@ -131,32 +131,36 @@ export {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function listUserVideos (req: express.Request, res: express.Response) {
|
||||
async function listMyVideos (req: express.Request, res: express.Response) {
|
||||
const user = res.locals.oauth.token.User
|
||||
const countVideos = getCountVideos(req)
|
||||
const query = pickCommonVideoQuery(req.query)
|
||||
|
||||
const include = (query.include || VideoInclude.NONE) | VideoInclude.BLACKLISTED | VideoInclude.NOT_PUBLISHED_STATE
|
||||
|
||||
const apiOptions = await Hooks.wrapObject({
|
||||
privacyOneOf: getAllPrivacies(),
|
||||
const apiOptions = await Hooks.wrapObject(
|
||||
{
|
||||
privacyOneOf: getAllPrivacies(),
|
||||
|
||||
...query,
|
||||
...query,
|
||||
|
||||
// Display all
|
||||
nsfw: null,
|
||||
// Display all
|
||||
nsfw: null,
|
||||
|
||||
user,
|
||||
accountId: user.Account.id,
|
||||
displayOnlyForFollower: null,
|
||||
user,
|
||||
accountId: user.Account.id,
|
||||
displayOnlyForFollower: null,
|
||||
|
||||
videoChannelId: res.locals.videoChannel?.id,
|
||||
channelNameOneOf: req.query.channelNameOneOf,
|
||||
videoChannelId: res.locals.videoChannel?.id,
|
||||
channelNameOneOf: req.query.channelNameOneOf,
|
||||
includeCollaborations: req.query.includeCollaborations || false,
|
||||
|
||||
countVideos,
|
||||
countVideos,
|
||||
|
||||
include
|
||||
}, 'filter:api.user.me.videos.list.params')
|
||||
include
|
||||
} satisfies Parameters<typeof VideoModel.listForApi>[0],
|
||||
'filter:api.user.me.videos.list.params'
|
||||
)
|
||||
|
||||
const resultList = await Hooks.wrapPromiseFun(
|
||||
VideoModel.listForApi.bind(VideoModel),
|
||||
|
@ -170,7 +174,7 @@ async function listUserVideos (req: express.Request, res: express.Response) {
|
|||
async function listCommentsOnUserVideos (req: express.Request, res: express.Response) {
|
||||
const userAccount = res.locals.oauth.token.User.Account
|
||||
|
||||
const options = {
|
||||
const resultList = await VideoCommentModel.listCommentsForApi({
|
||||
...pick(req.query, [
|
||||
'start',
|
||||
'count',
|
||||
|
@ -182,14 +186,15 @@ async function listCommentsOnUserVideos (req: express.Request, res: express.Resp
|
|||
]),
|
||||
|
||||
autoTagOfAccountId: userAccount.id,
|
||||
|
||||
videoAccountOwnerId: userAccount.id,
|
||||
videoAccountOwnerIncludeCollaborations: req.query.includeCollaborations || false,
|
||||
|
||||
heldForReview: req.query.isHeldForReview,
|
||||
|
||||
videoChannelOwnerId: res.locals.videoChannel?.id,
|
||||
videoId: res.locals.videoAll?.id
|
||||
}
|
||||
|
||||
const resultList = await VideoCommentModel.listCommentsForApi(options)
|
||||
})
|
||||
|
||||
return res.json({
|
||||
total: resultList.total,
|
||||
|
@ -197,7 +202,7 @@ async function listCommentsOnUserVideos (req: express.Request, res: express.Resp
|
|||
})
|
||||
}
|
||||
|
||||
async function getUserVideoImports (req: express.Request, res: express.Response) {
|
||||
async function listMyVideoImports (req: express.Request, res: express.Response) {
|
||||
const user = res.locals.oauth.token.User
|
||||
const resultList = await VideoImportModel.listUserVideoImportsForApi({
|
||||
userId: user.id,
|
||||
|
@ -208,7 +213,7 @@ async function getUserVideoImports (req: express.Request, res: express.Response)
|
|||
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||
}
|
||||
|
||||
async function getUserInformation (req: express.Request, res: express.Response) {
|
||||
async function getMyInformation (req: express.Request, res: express.Response) {
|
||||
// We did not load channels in res.locals.user
|
||||
const user = await UserModel.loadForMeAPI(res.locals.oauth.token.user.id)
|
||||
|
||||
|
@ -221,7 +226,7 @@ async function getUserInformation (req: express.Request, res: express.Response)
|
|||
return res.json(result)
|
||||
}
|
||||
|
||||
async function getUserVideoQuotaUsed (req: express.Request, res: express.Response) {
|
||||
async function getMyVideoQuotaUsed (req: express.Request, res: express.Response) {
|
||||
const user = res.locals.oauth.token.user
|
||||
const videoQuotaUsed = await getOriginalVideoFileTotalFromUser(user)
|
||||
const videoQuotaUsedDaily = await getOriginalVideoFileTotalDailyFromUser(user)
|
||||
|
@ -233,7 +238,7 @@ async function getUserVideoQuotaUsed (req: express.Request, res: express.Respons
|
|||
return res.json(data)
|
||||
}
|
||||
|
||||
async function getUserVideoRating (req: express.Request, res: express.Response) {
|
||||
async function getMyVideoRating (req: express.Request, res: express.Response) {
|
||||
const videoId = res.locals.videoId.id
|
||||
const accountId = +res.locals.oauth.token.User.Account.id
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue