-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'
asyncMiddleware,
executeIfActivityPub,
localAccountValidator,
- localVideoChannelValidator,
+ videoChannelsNameWithHostValidator,
+ ensureIsLocalChannel,
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'
import { AccountModel } from '../../models/account/account'
import { AccountVideoRateModel } from '../../models/account/account-video-rate'
import { ActorFollowModel } from '../../models/actor/actor-follow'
-import { VideoModel } from '../../models/video/video'
import { VideoCaptionModel } from '../../models/video/video-caption'
import { VideoCommentModel } from '../../models/video/video-comment'
import { VideoPlaylistModel } from '../../models/video/video-playlist'
// Intercept ActivityPub client requests
activityPubClientRouter.get(
- [ '/accounts?/:name', '/accounts?/:name/video-channels' ],
+ [ '/accounts?/:name', '/accounts?/:name/video-channels', '/a/:name', '/a/:name/video-channels' ],
executeIfActivityPub,
asyncMiddleware(localAccountValidator),
accountController
getAccountVideoRateFactory('dislike')
)
-activityPubClientRouter.get('/videos/watch/:id',
+activityPubClientRouter.get(
+ [ '/videos/watch/:id', '/w/:id' ],
executeIfActivityPub,
- asyncMiddleware(cacheRoute()(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS)),
- asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
+ cacheRoute(ROUTE_CACHE_LIFETIME.ACTIVITY_PUB.VIDEOS),
+ asyncMiddleware(videosCustomGetValidator('all')),
asyncMiddleware(videoController)
)
activityPubClientRouter.get('/videos/watch/:id/activity',
executeIfActivityPub,
- asyncMiddleware(videosCustomGetValidator('only-video-with-rights')),
+ asyncMiddleware(videosCustomGetValidator('all')),
asyncMiddleware(videoController)
)
activityPubClientRouter.get('/videos/watch/:id/announces',
)
activityPubClientRouter.get(
- [ '/video-channels/:name', '/video-channels/: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)
}
async function videoController (req: express.Request, res: express.Response) {
- // We need more attributes
- const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(res.locals.onlyVideoWithRights.id)
+ const video = res.locals.videoAll
if (redirectIfNotOwned(video.url, res)) return