aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-02-04 15:00:47 +0100
committerChocobozzz <me@florianbigard.com>2020-02-04 15:00:47 +0100
commit7eba5e1fa81c8e54cb8fe298a96e8070afa50921 (patch)
treea6bd4b13dc0d65addfa82fcf200f2d1853a0723a /server/controllers
parente436baf0b00b3ecf3731aeba02437ebe4906ac5f (diff)
downloadPeerTube-7eba5e1fa81c8e54cb8fe298a96e8070afa50921.tar.gz
PeerTube-7eba5e1fa81c8e54cb8fe298a96e8070afa50921.tar.zst
PeerTube-7eba5e1fa81c8e54cb8fe298a96e8070afa50921.zip
Add model cache for video
When fetching only immutable attributes
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/activitypub/client.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index 2812bfe1e..9a5fd6084 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -37,7 +37,7 @@ import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike'
37import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' 37import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
38import { VideoPlaylistModel } from '../../models/video/video-playlist' 38import { VideoPlaylistModel } from '../../models/video/video-playlist'
39import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 39import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
40import { MAccountId, MActorId, MVideo, MVideoAPWithoutCaption } from '@server/typings/models' 40import { MAccountId, MActorId, MVideo, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models'
41 41
42const activityPubClientRouter = express.Router() 42const activityPubClientRouter = express.Router()
43 43
@@ -85,7 +85,7 @@ activityPubClientRouter.get('/videos/watch/:id/activity',
85) 85)
86activityPubClientRouter.get('/videos/watch/:id/announces', 86activityPubClientRouter.get('/videos/watch/:id/announces',
87 executeIfActivityPub, 87 executeIfActivityPub,
88 asyncMiddleware(videosCustomGetValidator('only-video')), 88 asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')),
89 asyncMiddleware(videoAnnouncesController) 89 asyncMiddleware(videoAnnouncesController)
90) 90)
91activityPubClientRouter.get('/videos/watch/:id/announces/:actorId', 91activityPubClientRouter.get('/videos/watch/:id/announces/:actorId',
@@ -95,17 +95,17 @@ activityPubClientRouter.get('/videos/watch/:id/announces/:actorId',
95) 95)
96activityPubClientRouter.get('/videos/watch/:id/likes', 96activityPubClientRouter.get('/videos/watch/:id/likes',
97 executeIfActivityPub, 97 executeIfActivityPub,
98 asyncMiddleware(videosCustomGetValidator('only-video')), 98 asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')),
99 asyncMiddleware(videoLikesController) 99 asyncMiddleware(videoLikesController)
100) 100)
101activityPubClientRouter.get('/videos/watch/:id/dislikes', 101activityPubClientRouter.get('/videos/watch/:id/dislikes',
102 executeIfActivityPub, 102 executeIfActivityPub,
103 asyncMiddleware(videosCustomGetValidator('only-video')), 103 asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')),
104 asyncMiddleware(videoDislikesController) 104 asyncMiddleware(videoDislikesController)
105) 105)
106activityPubClientRouter.get('/videos/watch/:id/comments', 106activityPubClientRouter.get('/videos/watch/:id/comments',
107 executeIfActivityPub, 107 executeIfActivityPub,
108 asyncMiddleware(videosCustomGetValidator('only-video')), 108 asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')),
109 asyncMiddleware(videoCommentsController) 109 asyncMiddleware(videoCommentsController)
110) 110)
111activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId', 111activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId',
@@ -238,7 +238,7 @@ async function videoAnnounceController (req: express.Request, res: express.Respo
238} 238}
239 239
240async function videoAnnouncesController (req: express.Request, res: express.Response) { 240async function videoAnnouncesController (req: express.Request, res: express.Response) {
241 const video = res.locals.onlyVideo 241 const video = res.locals.onlyImmutableVideo
242 242
243 const handler = async (start: number, count: number) => { 243 const handler = async (start: number, count: number) => {
244 const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count) 244 const result = await VideoShareModel.listAndCountByVideoId(video.id, start, count)
@@ -253,21 +253,21 @@ async function videoAnnouncesController (req: express.Request, res: express.Resp
253} 253}
254 254
255async function videoLikesController (req: express.Request, res: express.Response) { 255async function videoLikesController (req: express.Request, res: express.Response) {
256 const video = res.locals.onlyVideo 256 const video = res.locals.onlyImmutableVideo
257 const json = await videoRates(req, 'like', video, getVideoLikesActivityPubUrl(video)) 257 const json = await videoRates(req, 'like', video, getVideoLikesActivityPubUrl(video))
258 258
259 return activityPubResponse(activityPubContextify(json), res) 259 return activityPubResponse(activityPubContextify(json), res)
260} 260}
261 261
262async function videoDislikesController (req: express.Request, res: express.Response) { 262async function videoDislikesController (req: express.Request, res: express.Response) {
263 const video = res.locals.onlyVideo 263 const video = res.locals.onlyImmutableVideo
264 const json = await videoRates(req, 'dislike', video, getVideoDislikesActivityPubUrl(video)) 264 const json = await videoRates(req, 'dislike', video, getVideoDislikesActivityPubUrl(video))
265 265
266 return activityPubResponse(activityPubContextify(json), res) 266 return activityPubResponse(activityPubContextify(json), res)
267} 267}
268 268
269async function videoCommentsController (req: express.Request, res: express.Response) { 269async function videoCommentsController (req: express.Request, res: express.Response) {
270 const video = res.locals.onlyVideo 270 const video = res.locals.onlyImmutableVideo
271 271
272 const handler = async (start: number, count: number) => { 272 const handler = async (start: number, count: number) => {
273 const result = await VideoCommentModel.listAndCountByVideoId(video.id, start, count) 273 const result = await VideoCommentModel.listAndCountByVideoId(video.id, start, count)
@@ -386,7 +386,7 @@ async function actorPlaylists (req: express.Request, account: MAccountId) {
386 return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page) 386 return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
387} 387}
388 388
389function videoRates (req: express.Request, rateType: VideoRateType, video: MVideo, url: string) { 389function videoRates (req: express.Request, rateType: VideoRateType, video: MVideoId, url: string) {
390 const handler = async (start: number, count: number) => { 390 const handler = async (start: number, count: number) => {
391 const result = await AccountVideoRateModel.listAndCountAccountUrlsByVideoId(rateType, video.id, start, count) 391 const result = await AccountVideoRateModel.listAndCountAccountUrlsByVideoId(rateType, video.id, start, count)
392 return { 392 return {