-import * as cors from 'cors'
-import * as express from 'express'
+import cors from 'cors'
+import express from 'express'
import { getServerActor } from '@server/models/application/application'
import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models'
import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
} from '../../lib/activitypub/url'
import {
asyncMiddleware,
+ ensureIsLocalChannel,
executeIfActivityPub,
localAccountValidator,
- localVideoChannelValidator,
+ videoChannelsNameWithHostValidator,
videosCustomGetValidator,
videosShareValidator
} from '../../middlewares'
-import { cacheRoute } from '../../middlewares/cache'
+import { cacheRoute } from '../../middlewares/cache/cache'
import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators'
import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy'
import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
activityPubClientRouter.get(
[ '/videos/watch/:id', '/w/:id' ],
executeIfActivityPub,
- asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS)),
+ cacheRoute(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS),
asyncMiddleware(videosCustomGetValidator('all')),
asyncMiddleware(videoController)
)
)
activityPubClientRouter.get(
- [ '/video-channels/:name', '/video-channels/:name/videos', '/c/:name', '/c/:name/videos' ],
+ [ '/video-channels/:nameWithHost', '/video-channels/:nameWithHost/videos', '/c/:nameWithHost', '/c/:nameWithHost/videos' ],
executeIfActivityPub,
- asyncMiddleware(localVideoChannelValidator),
+ asyncMiddleware(videoChannelsNameWithHostValidator),
+ ensureIsLocalChannel,
videoChannelController
)
-activityPubClientRouter.get('/video-channels/:name/followers',
+activityPubClientRouter.get('/video-channels/:nameWithHost/followers',
executeIfActivityPub,
- asyncMiddleware(localVideoChannelValidator),
+ asyncMiddleware(videoChannelsNameWithHostValidator),
+ ensureIsLocalChannel,
asyncMiddleware(videoChannelFollowersController)
)
-activityPubClientRouter.get('/video-channels/:name/following',
+activityPubClientRouter.get('/video-channels/:nameWithHost/following',
executeIfActivityPub,
- asyncMiddleware(localVideoChannelValidator),
+ asyncMiddleware(videoChannelsNameWithHostValidator),
+ ensureIsLocalChannel,
asyncMiddleware(videoChannelFollowingController)
)
-activityPubClientRouter.get('/video-channels/:name/playlists',
+activityPubClientRouter.get('/video-channels/:nameWithHost/playlists',
executeIfActivityPub,
- asyncMiddleware(localVideoChannelValidator),
+ asyncMiddleware(videoChannelsNameWithHostValidator),
+ ensureIsLocalChannel,
asyncMiddleware(videoChannelPlaylistsController)
)
asyncMiddleware(videoRedundancyController)
)
-activityPubClientRouter.get('/video-playlists/:playlistId',
+activityPubClientRouter.get(
+ [ '/video-playlists/:playlistId', '/videos/watch/playlist/:playlistId', '/w/p/:playlistId' ],
executeIfActivityPub,
asyncMiddleware(videoPlaylistsGetValidator('all')),
asyncMiddleware(videoPlaylistController)
const handler = async (start: number, count: number) => {
const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count)
return {
- total: result.count,
- data: result.rows.map(r => r.url)
+ total: result.total,
+ data: result.data.map(r => r.url)
}
}
const json = await activityPubCollectionPagination(getLocalVideoSharesActivityPubUrl(video), handler, req.query.page)
const handler = async (start: number, count: number) => {
const result = await VideoCommentModel.listAndCountByVideoForAP(video, start, count)
+
return {
- total: result.count,
- data: result.rows.map(r => r.url)
+ total: result.total,
+ data: result.data.map(r => r.url)
}
}
const json = await activityPubCollectionPagination(getLocalVideoCommentsActivityPubUrl(video), handler, req.query.page)
const handler = async (start: number, count: number) => {
const result = await AccountVideoRateModel.listAndCountAccountUrlsByVideoId(rateType, video.id, start, count)
return {
- total: result.count,
- data: result.rows.map(r => r.url)
+ total: result.total,
+ data: result.data.map(r => r.url)
}
}
return activityPubCollectionPagination(url, handler, req.query.page)