aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/videos/shared
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/lib/activitypub/videos/shared
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/lib/activitypub/videos/shared')
-rw-r--r--server/lib/activitypub/videos/shared/object-to-model-attributes.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
index c97217669..f02b9cba6 100644
--- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
+++ b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
@@ -24,6 +24,7 @@ import {
24 VideoPrivacy, 24 VideoPrivacy,
25 VideoStreamingPlaylistType 25 VideoStreamingPlaylistType
26} from '@shared/models' 26} from '@shared/models'
27import { getDurationFromActivityStream } from '../../activity'
27 28
28function getThumbnailFromIcons (videoObject: VideoObject) { 29function getThumbnailFromIcons (videoObject: VideoObject) {
29 let validIcons = videoObject.icon.filter(i => i.width > THUMBNAILS_SIZE.minWidth) 30 let validIcons = videoObject.icon.filter(i => i.width > THUMBNAILS_SIZE.minWidth)
@@ -170,7 +171,6 @@ function getVideoAttributesFromObject (videoChannel: MChannelId, videoObject: Vi
170 ? VideoPrivacy.PUBLIC 171 ? VideoPrivacy.PUBLIC
171 : VideoPrivacy.UNLISTED 172 : VideoPrivacy.UNLISTED
172 173
173 const duration = videoObject.duration.replace(/[^\d]+/, '')
174 const language = videoObject.language?.identifier 174 const language = videoObject.language?.identifier
175 175
176 const category = videoObject.category 176 const category = videoObject.category
@@ -200,7 +200,7 @@ function getVideoAttributesFromObject (videoChannel: MChannelId, videoObject: Vi
200 isLive: videoObject.isLiveBroadcast, 200 isLive: videoObject.isLiveBroadcast,
201 state: videoObject.state, 201 state: videoObject.state,
202 channelId: videoChannel.id, 202 channelId: videoChannel.id,
203 duration: parseInt(duration, 10), 203 duration: getDurationFromActivityStream(videoObject.duration),
204 createdAt: new Date(videoObject.published), 204 createdAt: new Date(videoObject.published),
205 publishedAt: new Date(videoObject.published), 205 publishedAt: new Date(videoObject.published),
206 206