aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/activitypub/client.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-24 13:36:47 +0100
committerChocobozzz <chocobozzz@cpy.re>2022-04-15 09:49:35 +0200
commitb211106695bb82f6c32e53306081b5262c3d109d (patch)
treefa187de1c33b0956665f5362e29af6b0f6d8bb57 /server/controllers/activitypub/client.ts
parent69d48ee30c9d47cddf0c3c047dc99a99dcb6e894 (diff)
downloadPeerTube-b211106695bb82f6c32e53306081b5262c3d109d.tar.gz
PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.tar.zst
PeerTube-b211106695bb82f6c32e53306081b5262c3d109d.zip
Support video views/viewers stats in server
* Add "currentTime" and "event" body params to view endpoint * Merge watching and view endpoints * Introduce WatchAction AP activity * Add tables to store viewer information of local videos * Add endpoints to fetch video views/viewers stats of local videos * Refactor views/viewers handlers * Support "views" and "viewers" counters for both VOD and live videos
Diffstat (limited to 'server/controllers/activitypub/client.ts')
-rw-r--r--server/controllers/activitypub/client.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index d0f761009..8e064fb5b 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -27,7 +27,7 @@ import {
27 videosShareValidator 27 videosShareValidator
28} from '../../middlewares' 28} from '../../middlewares'
29import { cacheRoute } from '../../middlewares/cache/cache' 29import { cacheRoute } from '../../middlewares/cache/cache'
30import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators' 30import { getAccountVideoRateValidatorFactory, getVideoLocalViewerValidator, videoCommentGetValidator } from '../../middlewares/validators'
31import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' 31import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy'
32import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' 32import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
33import { AccountModel } from '../../models/account/account' 33import { AccountModel } from '../../models/account/account'
@@ -175,6 +175,12 @@ activityPubClientRouter.get('/video-playlists/:playlistId/videos/:playlistElemen
175 videoPlaylistElementController 175 videoPlaylistElementController
176) 176)
177 177
178activityPubClientRouter.get('/videos/local-viewer/:localViewerId',
179 executeIfActivityPub,
180 asyncMiddleware(getVideoLocalViewerValidator),
181 getVideoLocalViewerController
182)
183
178// --------------------------------------------------------------------------- 184// ---------------------------------------------------------------------------
179 185
180export { 186export {
@@ -399,6 +405,12 @@ function videoPlaylistElementController (req: express.Request, res: express.Resp
399 return activityPubResponse(activityPubContextify(json, 'Playlist'), res) 405 return activityPubResponse(activityPubContextify(json, 'Playlist'), res)
400} 406}
401 407
408function getVideoLocalViewerController (req: express.Request, res: express.Response) {
409 const localViewer = res.locals.localViewerFull
410
411 return activityPubResponse(activityPubContextify(localViewer.toActivityPubObject(), 'WatchAction'), res)
412}
413
402// --------------------------------------------------------------------------- 414// ---------------------------------------------------------------------------
403 415
404function actorFollowing (req: express.Request, actor: MActorId) { 416function actorFollowing (req: express.Request, actor: MActorId) {