mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Add channel collaborators feature
This commit is contained in:
parent
94e55dfc6c
commit
135d5c7363
185 changed files with 5457 additions and 2631 deletions
|
@ -26,12 +26,16 @@ import {
|
|||
accountHandleGetValidatorFactory,
|
||||
accountsFollowersSortValidator,
|
||||
accountsSortValidator,
|
||||
listAccountChannelsValidator,
|
||||
videoChannelsSortValidator,
|
||||
videoChannelStatsValidator,
|
||||
videoChannelSyncsSortValidator,
|
||||
videosSortValidator
|
||||
} from '../../middlewares/validators/index.js'
|
||||
import { commonVideoPlaylistFiltersValidator, videoPlaylistsSearchValidator } from '../../middlewares/validators/videos/video-playlists.js'
|
||||
import {
|
||||
commonVideoPlaylistFiltersValidator,
|
||||
videoPlaylistsAccountValidator,
|
||||
videoPlaylistsSearchValidator
|
||||
} from '../../middlewares/validators/videos/video-playlists.js'
|
||||
import { AccountVideoRateModel } from '../../models/account/account-video-rate.js'
|
||||
import { AccountModel } from '../../models/account/account.js'
|
||||
import { guessAdditionalAttributesFromQuery } from '../../models/video/formatter/index.js'
|
||||
|
@ -54,13 +58,13 @@ accountsRouter.get(
|
|||
|
||||
accountsRouter.get(
|
||||
'/:handle',
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })),
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkCanManage: false })),
|
||||
getAccount
|
||||
)
|
||||
|
||||
accountsRouter.get(
|
||||
'/:handle/videos',
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })),
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkCanManage: false })),
|
||||
paginationValidator,
|
||||
videosSortValidator,
|
||||
setDefaultVideosSort,
|
||||
|
@ -72,8 +76,8 @@ accountsRouter.get(
|
|||
|
||||
accountsRouter.get(
|
||||
'/:handle/video-channels',
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })),
|
||||
videoChannelStatsValidator,
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkCanManage: false })),
|
||||
listAccountChannelsValidator,
|
||||
paginationValidator,
|
||||
videoChannelsSortValidator,
|
||||
setDefaultSort,
|
||||
|
@ -84,20 +88,21 @@ accountsRouter.get(
|
|||
accountsRouter.get(
|
||||
'/:handle/video-playlists',
|
||||
optionalAuthenticate,
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })),
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkCanManage: false })),
|
||||
paginationValidator,
|
||||
videoPlaylistsSortValidator,
|
||||
setDefaultSort,
|
||||
setDefaultPagination,
|
||||
commonVideoPlaylistFiltersValidator,
|
||||
videoPlaylistsSearchValidator,
|
||||
videoPlaylistsAccountValidator,
|
||||
asyncMiddleware(listAccountPlaylists)
|
||||
)
|
||||
|
||||
accountsRouter.get(
|
||||
'/:handle/video-channel-syncs',
|
||||
authenticate,
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: true })),
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkCanManage: true })),
|
||||
paginationValidator,
|
||||
videoChannelSyncsSortValidator,
|
||||
setDefaultSort,
|
||||
|
@ -108,7 +113,7 @@ accountsRouter.get(
|
|||
accountsRouter.get(
|
||||
'/:handle/ratings',
|
||||
authenticate,
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: true })),
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkCanManage: true })),
|
||||
paginationValidator,
|
||||
videoRatesSortValidator,
|
||||
setDefaultSort,
|
||||
|
@ -120,7 +125,7 @@ accountsRouter.get(
|
|||
accountsRouter.get(
|
||||
'/:handle/followers',
|
||||
authenticate,
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: true })),
|
||||
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkCanManage: true })),
|
||||
paginationValidator,
|
||||
accountsFollowersSortValidator,
|
||||
setDefaultSort,
|
||||
|
@ -153,16 +158,15 @@ async function listAccounts (req: express.Request, res: express.Response) {
|
|||
}
|
||||
|
||||
async function listAccountChannels (req: express.Request, res: express.Response) {
|
||||
const options = {
|
||||
const resultList = await VideoChannelModel.listByAccountForAPI({
|
||||
accountId: res.locals.account.id,
|
||||
start: req.query.start,
|
||||
count: req.query.count,
|
||||
sort: req.query.sort,
|
||||
withStats: req.query.withStats,
|
||||
includeCollaborations: req.query.includeCollaborations,
|
||||
search: req.query.search
|
||||
}
|
||||
|
||||
const resultList = await VideoChannelModel.listByAccountForAPI(options)
|
||||
})
|
||||
|
||||
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||
}
|
||||
|
@ -183,7 +187,7 @@ async function listAccountChannelsSync (req: express.Request, res: express.Respo
|
|||
|
||||
async function listAccountPlaylists (req: express.Request, res: express.Response) {
|
||||
const serverActor = await getServerActor()
|
||||
const query = req.query as VideoPlaylistsListQuery
|
||||
const query = req.query as VideoPlaylistsListQuery & { includeCollaborations?: boolean }
|
||||
|
||||
// Allow users to see their private/unlisted video playlists
|
||||
let listMyPlaylists = false
|
||||
|
@ -204,7 +208,9 @@ async function listAccountPlaylists (req: express.Request, res: express.Response
|
|||
sort: query.sort,
|
||||
search: query.search,
|
||||
|
||||
type: query.playlistType
|
||||
type: query.playlistType,
|
||||
|
||||
includeCollaborations: query.includeCollaborations
|
||||
})
|
||||
|
||||
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||
|
@ -260,7 +266,7 @@ async function listAccountRatings (req: express.Request, res: express.Response)
|
|||
async function listAccountFollowers (req: express.Request, res: express.Response) {
|
||||
const account = res.locals.account
|
||||
|
||||
const channels = await VideoChannelModel.listAllByAccount(account.id)
|
||||
const channels = await VideoChannelModel.listAllOwnedByAccount(account.id)
|
||||
const actorIds = [ account.actorId ].concat(channels.map(c => c.actorId))
|
||||
|
||||
const resultList = await ActorFollowModel.listFollowersForApi({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue