diff options
author | Chocobozzz <me@florianbigard.com> | 2022-03-24 13:36:47 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-04-15 09:49:35 +0200 |
commit | b211106695bb82f6c32e53306081b5262c3d109d (patch) | |
tree | fa187de1c33b0956665f5362e29af6b0f6d8bb57 /server/controllers/activitypub/client.ts | |
parent | 69d48ee30c9d47cddf0c3c047dc99a99dcb6e894 (diff) | |
download | PeerTube-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.ts | 14 |
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' |
29 | import { cacheRoute } from '../../middlewares/cache/cache' | 29 | import { cacheRoute } from '../../middlewares/cache/cache' |
30 | import { getAccountVideoRateValidatorFactory, videoCommentGetValidator } from '../../middlewares/validators' | 30 | import { getAccountVideoRateValidatorFactory, getVideoLocalViewerValidator, videoCommentGetValidator } from '../../middlewares/validators' |
31 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' | 31 | import { videoFileRedundancyGetValidator, videoPlaylistRedundancyGetValidator } from '../../middlewares/validators/redundancy' |
32 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' | 32 | import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' |
33 | import { AccountModel } from '../../models/account/account' | 33 | import { AccountModel } from '../../models/account/account' |
@@ -175,6 +175,12 @@ activityPubClientRouter.get('/video-playlists/:playlistId/videos/:playlistElemen | |||
175 | videoPlaylistElementController | 175 | videoPlaylistElementController |
176 | ) | 176 | ) |
177 | 177 | ||
178 | activityPubClientRouter.get('/videos/local-viewer/:localViewerId', | ||
179 | executeIfActivityPub, | ||
180 | asyncMiddleware(getVideoLocalViewerValidator), | ||
181 | getVideoLocalViewerController | ||
182 | ) | ||
183 | |||
178 | // --------------------------------------------------------------------------- | 184 | // --------------------------------------------------------------------------- |
179 | 185 | ||
180 | export { | 186 | export { |
@@ -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 | ||
408 | function 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 | ||
404 | function actorFollowing (req: express.Request, actor: MActorId) { | 416 | function actorFollowing (req: express.Request, actor: MActorId) { |