1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Use handle for param name

This commit is contained in:
Chocobozzz 2025-04-10 09:44:50 +02:00
parent ade57193ac
commit 6f68db1be9
No known key found for this signature in database
GPG key ID: 583A612D890159BE
9 changed files with 34 additions and 41 deletions

View file

@ -62,7 +62,6 @@ describe('Test multiple servers', function () {
}) })
describe('Should upload the video and propagate on each server', function () { describe('Should upload the video and propagate on each server', function () {
it('Should upload the video on server 1 and propagate on each server', async function () { it('Should upload the video on server 1 and propagate on each server', async function () {
this.timeout(60000) this.timeout(60000)
@ -362,7 +361,6 @@ describe('Test multiple servers', function () {
}) })
describe('Local videos listing', function () { describe('Local videos listing', function () {
it('Should list only local videos on server 1', async function () { it('Should list only local videos on server 1', async function () {
const { data, total } = await servers[0].videos.list({ isLocal: true }) const { data, total } = await servers[0].videos.list({ isLocal: true })
@ -393,7 +391,6 @@ describe('Test multiple servers', function () {
}) })
describe('All videos listing', function () { describe('All videos listing', function () {
it('Should list and sort by "localVideoFilesSize"', async function () { it('Should list and sort by "localVideoFilesSize"', async function () {
const { data, total } = await servers[2].videos.list({ sort: '-localVideoFilesSize' }) const { data, total } = await servers[2].videos.list({ sort: '-localVideoFilesSize' })
@ -408,7 +405,6 @@ describe('Test multiple servers', function () {
}) })
describe('Should seed the uploaded video', function () { describe('Should seed the uploaded video', function () {
it('Should add the file 1 by asking server 3', async function () { it('Should add the file 1 by asking server 3', async function () {
this.retries(2) this.retries(2)
this.timeout(30000) this.timeout(30000)
@ -1038,7 +1034,6 @@ describe('Test multiple servers', function () {
}) })
describe('With minimum parameters', function () { describe('With minimum parameters', function () {
it('Should upload and propagate the video', async function () { it('Should upload and propagate the video', async function () {
this.timeout(240000) this.timeout(240000)
@ -1120,13 +1115,11 @@ describe('Test multiple servers', function () {
}) })
describe('TMP directory', function () { describe('TMP directory', function () {
it('Should have an empty tmp directory', async function () { it('Should have an empty tmp directory', async function () {
for (const server of servers) { for (const server of servers) {
await checkTmpIsEmpty(server) await checkTmpIsEmpty(server)
} }
}) })
}) })
after(async function () { after(async function () {

View file

@ -64,28 +64,28 @@ activityPubClientRouter.use(cors())
// Intercept ActivityPub client requests // Intercept ActivityPub client requests
activityPubClientRouter.get( activityPubClientRouter.get(
[ '/accounts?/:name', '/accounts?/:name/video-channels', '/a/:name', '/a/:name/video-channels' ], [ '/accounts?/:handle', '/accounts?/:handle/video-channels', '/a/:handle', '/a/:handle/video-channels' ],
executeIfActivityPub, executeIfActivityPub,
activityPubRateLimiter, activityPubRateLimiter,
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false })),
asyncMiddleware(accountController) asyncMiddleware(accountController)
) )
activityPubClientRouter.get( activityPubClientRouter.get(
'/accounts?/:name/followers', '/accounts?/:handle/followers',
executeIfActivityPub, executeIfActivityPub,
activityPubRateLimiter, activityPubRateLimiter,
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false })),
asyncMiddleware(accountFollowersController) asyncMiddleware(accountFollowersController)
) )
activityPubClientRouter.get( activityPubClientRouter.get(
'/accounts?/:name/following', '/accounts?/:handle/following',
executeIfActivityPub, executeIfActivityPub,
activityPubRateLimiter, activityPubRateLimiter,
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false })),
asyncMiddleware(accountFollowingController) asyncMiddleware(accountFollowingController)
) )
activityPubClientRouter.get( activityPubClientRouter.get(
'/accounts?/:name/playlists', '/accounts?/:handle/playlists',
executeIfActivityPub, executeIfActivityPub,
activityPubRateLimiter, activityPubRateLimiter,
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false })),
@ -208,28 +208,28 @@ activityPubClientRouter.get(
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
activityPubClientRouter.get( activityPubClientRouter.get(
[ '/video-channels/:nameWithHost', '/video-channels/:nameWithHost/videos', '/c/:nameWithHost', '/c/:nameWithHost/videos' ], [ '/video-channels/:handle', '/video-channels/:handle/videos', '/c/:handle', '/c/:handle/videos' ],
executeIfActivityPub, executeIfActivityPub,
activityPubRateLimiter, activityPubRateLimiter,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })),
asyncMiddleware(videoChannelController) asyncMiddleware(videoChannelController)
) )
activityPubClientRouter.get( activityPubClientRouter.get(
'/video-channels/:nameWithHost/followers', '/video-channels/:handle/followers',
executeIfActivityPub, executeIfActivityPub,
activityPubRateLimiter, activityPubRateLimiter,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })),
asyncMiddleware(videoChannelFollowersController) asyncMiddleware(videoChannelFollowersController)
) )
activityPubClientRouter.get( activityPubClientRouter.get(
'/video-channels/:nameWithHost/following', '/video-channels/:handle/following',
executeIfActivityPub, executeIfActivityPub,
activityPubRateLimiter, activityPubRateLimiter,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })),
asyncMiddleware(videoChannelFollowingController) asyncMiddleware(videoChannelFollowingController)
) )
activityPubClientRouter.get( activityPubClientRouter.get(
'/video-channels/:nameWithHost/playlists', '/video-channels/:handle/playlists',
executeIfActivityPub, executeIfActivityPub,
activityPubRateLimiter, activityPubRateLimiter,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })),

View file

@ -25,7 +25,7 @@ inboxRouter.post(
) )
inboxRouter.post( inboxRouter.post(
'/accounts/:name/inbox', '/accounts/:handle/inbox',
activityPubRateLimiter, activityPubRateLimiter,
signatureValidator, signatureValidator,
asyncMiddleware(checkSignature), asyncMiddleware(checkSignature),
@ -35,7 +35,7 @@ inboxRouter.post(
) )
inboxRouter.post( inboxRouter.post(
'/video-channels/:nameWithHost/inbox', '/video-channels/:handle/inbox',
activityPubRateLimiter, activityPubRateLimiter,
signatureValidator, signatureValidator,
asyncMiddleware(checkSignature), asyncMiddleware(checkSignature),

View file

@ -20,7 +20,7 @@ import { activityPubResponse } from './utils.js'
const outboxRouter = express.Router() const outboxRouter = express.Router()
outboxRouter.get( outboxRouter.get(
'/accounts/:name/outbox', '/accounts/:handle/outbox',
activityPubRateLimiter, activityPubRateLimiter,
apPaginationValidator, apPaginationValidator,
accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false }), accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: false }),
@ -28,7 +28,7 @@ outboxRouter.get(
) )
outboxRouter.get( outboxRouter.get(
'/video-channels/:nameWithHost/outbox', '/video-channels/:handle/outbox',
activityPubRateLimiter, activityPubRateLimiter,
apPaginationValidator, apPaginationValidator,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: false })),

View file

@ -52,13 +52,13 @@ accountsRouter.get(
) )
accountsRouter.get( accountsRouter.get(
'/:accountName', '/:handle',
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })),
getAccount getAccount
) )
accountsRouter.get( accountsRouter.get(
'/:accountName/videos', '/:handle/videos',
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })),
paginationValidator, paginationValidator,
videosSortValidator, videosSortValidator,
@ -70,7 +70,7 @@ accountsRouter.get(
) )
accountsRouter.get( accountsRouter.get(
'/:accountName/video-channels', '/:handle/video-channels',
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })),
videoChannelStatsValidator, videoChannelStatsValidator,
paginationValidator, paginationValidator,
@ -81,7 +81,7 @@ accountsRouter.get(
) )
accountsRouter.get( accountsRouter.get(
'/:accountName/video-playlists', '/:handle/video-playlists',
optionalAuthenticate, optionalAuthenticate,
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })),
paginationValidator, paginationValidator,
@ -94,7 +94,7 @@ accountsRouter.get(
) )
accountsRouter.get( accountsRouter.get(
'/:accountName/video-channel-syncs', '/:handle/video-channel-syncs',
authenticate, authenticate,
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: true })),
paginationValidator, paginationValidator,
@ -105,7 +105,7 @@ accountsRouter.get(
) )
accountsRouter.get( accountsRouter.get(
'/:accountName/ratings', '/:handle/ratings',
authenticate, authenticate,
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: true })),
paginationValidator, paginationValidator,
@ -117,7 +117,7 @@ accountsRouter.get(
) )
accountsRouter.get( accountsRouter.get(
'/:accountName/followers', '/:handle/followers',
authenticate, authenticate,
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: true, checkManage: true })),
paginationValidator, paginationValidator,

View file

@ -76,7 +76,7 @@ videoChannelRouter.get(
videoChannelRouter.post('/', authenticate, asyncMiddleware(videoChannelsAddValidator), asyncRetryTransactionMiddleware(createVideoChannel)) videoChannelRouter.post('/', authenticate, asyncMiddleware(videoChannelsAddValidator), asyncRetryTransactionMiddleware(createVideoChannel))
videoChannelRouter.post( videoChannelRouter.post(
'/:nameWithHost/avatar/pick', '/:handle/avatar/pick',
authenticate, authenticate,
reqAvatarFile, reqAvatarFile,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })),
@ -85,7 +85,7 @@ videoChannelRouter.post(
) )
videoChannelRouter.post( videoChannelRouter.post(
'/:nameWithHost/banner/pick', '/:handle/banner/pick',
authenticate, authenticate,
reqBannerFile, reqBannerFile,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })),
@ -94,21 +94,21 @@ videoChannelRouter.post(
) )
videoChannelRouter.delete( videoChannelRouter.delete(
'/:nameWithHost/avatar', '/:handle/avatar',
authenticate, authenticate,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })),
asyncMiddleware(deleteVideoChannelAvatar) asyncMiddleware(deleteVideoChannelAvatar)
) )
videoChannelRouter.delete( videoChannelRouter.delete(
'/:nameWithHost/banner', '/:handle/banner',
authenticate, authenticate,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })),
asyncMiddleware(deleteVideoChannelBanner) asyncMiddleware(deleteVideoChannelBanner)
) )
videoChannelRouter.put( videoChannelRouter.put(
'/:nameWithHost', '/:handle',
authenticate, authenticate,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })),
videoChannelsUpdateValidator, videoChannelsUpdateValidator,
@ -116,7 +116,7 @@ videoChannelRouter.put(
) )
videoChannelRouter.delete( videoChannelRouter.delete(
'/:nameWithHost', '/:handle',
authenticate, authenticate,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })),
asyncMiddleware(videoChannelsRemoveValidator), asyncMiddleware(videoChannelsRemoveValidator),
@ -124,13 +124,13 @@ videoChannelRouter.delete(
) )
videoChannelRouter.get( videoChannelRouter.get(
'/:nameWithHost', '/:handle',
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: false, checkManage: false })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: false, checkManage: false })),
asyncMiddleware(getVideoChannel) asyncMiddleware(getVideoChannel)
) )
videoChannelRouter.get( videoChannelRouter.get(
'/:nameWithHost/video-playlists', '/:handle/video-playlists',
optionalAuthenticate, optionalAuthenticate,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: false, checkManage: false })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: false, checkManage: false })),
paginationValidator, paginationValidator,
@ -142,7 +142,7 @@ videoChannelRouter.get(
) )
videoChannelRouter.get( videoChannelRouter.get(
'/:nameWithHost/videos', '/:handle/videos',
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: false, checkManage: false })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: false, checkManage: false })),
paginationValidator, paginationValidator,
videosSortValidator, videosSortValidator,
@ -154,7 +154,7 @@ videoChannelRouter.get(
) )
videoChannelRouter.get( videoChannelRouter.get(
'/:nameWithHost/followers', '/:handle/followers',
authenticate, authenticate,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: false, checkManage: true })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: false, checkManage: true })),
paginationValidator, paginationValidator,
@ -165,7 +165,7 @@ videoChannelRouter.get(
) )
videoChannelRouter.post( videoChannelRouter.post(
'/:nameWithHost/import-videos', '/:handle/import-videos',
authenticate, authenticate,
asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })), asyncMiddleware(videoChannelsHandleValidatorFactory({ checkIsLocal: true, checkManage: true })),
asyncMiddleware(videoChannelImportVideosValidator), asyncMiddleware(videoChannelImportVideosValidator),

View file

@ -10,7 +10,7 @@ const servicesRouter = express.Router()
servicesRouter.use('/oembed', cors(), apiRateLimiter, asyncMiddleware(oembedValidator), generateOEmbed) servicesRouter.use('/oembed', cors(), apiRateLimiter, asyncMiddleware(oembedValidator), generateOEmbed)
servicesRouter.use( servicesRouter.use(
'/redirect/accounts/:accountName', '/redirect/accounts/:handle',
apiRateLimiter, apiRateLimiter,
asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })), asyncMiddleware(accountHandleGetValidatorFactory({ checkIsLocal: false, checkManage: false })),
redirectToAccountUrl redirectToAccountUrl

View file

@ -10,7 +10,7 @@ export const accountHandleGetValidatorFactory = (options: {
const { checkManage, checkIsLocal } = options const { checkManage, checkIsLocal } = options
return [ return [
param('accountName') param('handle')
.exists(), .exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => { async (req: express.Request, res: express.Response, next: express.NextFunction) => {

View file

@ -89,7 +89,7 @@ export const videoChannelsHandleValidatorFactory = (options: {
const { checkIsLocal, checkManage } = options const { checkIsLocal, checkManage } = options
return [ return [
param('nameWithHost') param('handle')
.exists(), .exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => { async (req: express.Request, res: express.Response, next: express.NextFunction) => {