]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/activitypub/client.ts
Merge branch 'master' into release/3.3.0
[github/Chocobozzz/PeerTube.git] / server / controllers / activitypub / client.ts
index 356da7882770554c98b8771881fd0680183fb942..d7de1b9bdba4636ec7ff618e1904241db1c480da 100644 (file)
@@ -30,8 +30,7 @@ import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator }
 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/activitypub/actor-follow'
-import { VideoModel } from '../../models/video/video'
+import { ActorFollowModel } from '../../models/actor/actor-follow'
 import { VideoCaptionModel } from '../../models/video/video-caption'
 import { VideoCommentModel } from '../../models/video/video-comment'
 import { VideoPlaylistModel } from '../../models/video/video-playlist'
@@ -43,7 +42,8 @@ activityPubClientRouter.use(cors())
 
 // Intercept ActivityPub client requests
 
-activityPubClientRouter.get('/accounts?/:name',
+activityPubClientRouter.get(
+  [ '/accounts?/:name', '/accounts?/:name/video-channels', '/a/:name', '/a/:name/video-channels' ],
   executeIfActivityPub,
   asyncMiddleware(localAccountValidator),
   accountController
@@ -74,15 +74,16 @@ activityPubClientRouter.get('/accounts?/:name/dislikes/:videoId',
   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')),
+  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',
@@ -121,7 +122,8 @@ activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity
   asyncMiddleware(videoCommentController)
 )
 
-activityPubClientRouter.get('/video-channels/:name',
+activityPubClientRouter.get(
+  [ '/video-channels/:name', '/video-channels/:name/videos', '/c/:name', '/c/:name/videos' ],
   executeIfActivityPub,
   asyncMiddleware(localVideoChannelValidator),
   videoChannelController
@@ -153,7 +155,8 @@ activityPubClientRouter.get('/redundancy/streaming-playlists/:streamingPlaylistT
   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)
@@ -220,8 +223,7 @@ function getAccountVideoRateFactory (rateType: VideoRateType) {
 }
 
 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