aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-02 15:43:44 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitaf4ae64f6faf38f8179f2e07d3cd4ad60006be92 (patch)
treea2d39ddc138d49619f03f11e003c2302f824286c /server/models
parent77e9f859c6ad75ba179dec74e5410cc651eaa49b (diff)
downloadPeerTube-af4ae64f6faf38f8179f2e07d3cd4ad60006be92.tar.gz
PeerTube-af4ae64f6faf38f8179f2e07d3cd4ad60006be92.tar.zst
PeerTube-af4ae64f6faf38f8179f2e07d3cd4ad60006be92.zip
Begin live tests
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-format-utils.ts11
-rw-r--r--server/models/video/video-live.ts6
-rw-r--r--server/models/video/video.ts30
3 files changed, 41 insertions, 6 deletions
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts
index 92bde7773..04e636a15 100644
--- a/server/models/video/video-format-utils.ts
+++ b/server/models/video/video-format-utils.ts
@@ -352,11 +352,20 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject {
352 sensitive: video.nsfw, 352 sensitive: video.nsfw,
353 waitTranscoding: video.waitTranscoding, 353 waitTranscoding: video.waitTranscoding,
354 isLiveBroadcast: video.isLive, 354 isLiveBroadcast: video.isLive,
355
356 liveSaveReplay: video.isLive
357 ? video.VideoLive.saveReplay
358 : null,
359
355 state: video.state, 360 state: video.state,
356 commentsEnabled: video.commentsEnabled, 361 commentsEnabled: video.commentsEnabled,
357 downloadEnabled: video.downloadEnabled, 362 downloadEnabled: video.downloadEnabled,
358 published: video.publishedAt.toISOString(), 363 published: video.publishedAt.toISOString(),
359 originallyPublishedAt: video.originallyPublishedAt ? video.originallyPublishedAt.toISOString() : null, 364
365 originallyPublishedAt: video.originallyPublishedAt
366 ? video.originallyPublishedAt.toISOString()
367 : null,
368
360 updated: video.updatedAt.toISOString(), 369 updated: video.updatedAt.toISOString(),
361 mediaType: 'text/markdown', 370 mediaType: 'text/markdown',
362 content: video.description, 371 content: video.description,
diff --git a/server/models/video/video-live.ts b/server/models/video/video-live.ts
index 345918cb9..f3bff74ea 100644
--- a/server/models/video/video-live.ts
+++ b/server/models/video/video-live.ts
@@ -93,7 +93,11 @@ export class VideoLiveModel extends Model<VideoLiveModel> {
93 93
94 toFormattedJSON (): LiveVideo { 94 toFormattedJSON (): LiveVideo {
95 return { 95 return {
96 rtmpUrl: WEBSERVER.RTMP_URL, 96 // If we don't have a stream key, it means this is a remote live so we don't specify the rtmp URL
97 rtmpUrl: this.streamKey
98 ? WEBSERVER.RTMP_URL
99 : null,
100
97 streamKey: this.streamKey, 101 streamKey: this.streamKey,
98 saveReplay: this.saveReplay 102 saveReplay: this.saveReplay
99 } 103 }
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index d094f19b0..aba8c8cf4 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -26,6 +26,7 @@ import {
26} from 'sequelize-typescript' 26} from 'sequelize-typescript'
27import { buildNSFWFilter } from '@server/helpers/express-utils' 27import { buildNSFWFilter } from '@server/helpers/express-utils'
28import { getPrivaciesForFederation, isPrivacyForFederation } from '@server/helpers/video' 28import { getPrivaciesForFederation, isPrivacyForFederation } from '@server/helpers/video'
29import { LiveManager } from '@server/lib/live-manager'
29import { getHLSDirectory, getTorrentFileName, getTorrentFilePath, getVideoFilename, getVideoFilePath } from '@server/lib/video-paths' 30import { getHLSDirectory, getTorrentFileName, getTorrentFilePath, getVideoFilename, getVideoFilePath } from '@server/lib/video-paths'
30import { getServerActor } from '@server/models/application/application' 31import { getServerActor } from '@server/models/application/application'
31import { ModelCache } from '@server/models/model-cache' 32import { ModelCache } from '@server/models/model-cache'
@@ -121,14 +122,13 @@ import {
121 videoModelToFormattedJSON 122 videoModelToFormattedJSON
122} from './video-format-utils' 123} from './video-format-utils'
123import { VideoImportModel } from './video-import' 124import { VideoImportModel } from './video-import'
125import { VideoLiveModel } from './video-live'
124import { VideoPlaylistElementModel } from './video-playlist-element' 126import { VideoPlaylistElementModel } from './video-playlist-element'
125import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder' 127import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder'
126import { VideoShareModel } from './video-share' 128import { VideoShareModel } from './video-share'
127import { VideoStreamingPlaylistModel } from './video-streaming-playlist' 129import { VideoStreamingPlaylistModel } from './video-streaming-playlist'
128import { VideoTagModel } from './video-tag' 130import { VideoTagModel } from './video-tag'
129import { VideoViewModel } from './video-view' 131import { VideoViewModel } from './video-view'
130import { LiveManager } from '@server/lib/live-manager'
131import { VideoLiveModel } from './video-live'
132 132
133export enum ScopeNames { 133export enum ScopeNames {
134 AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', 134 AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS',
@@ -142,7 +142,8 @@ export enum ScopeNames {
142 WITH_STREAMING_PLAYLISTS = 'WITH_STREAMING_PLAYLISTS', 142 WITH_STREAMING_PLAYLISTS = 'WITH_STREAMING_PLAYLISTS',
143 WITH_USER_ID = 'WITH_USER_ID', 143 WITH_USER_ID = 'WITH_USER_ID',
144 WITH_IMMUTABLE_ATTRIBUTES = 'WITH_IMMUTABLE_ATTRIBUTES', 144 WITH_IMMUTABLE_ATTRIBUTES = 'WITH_IMMUTABLE_ATTRIBUTES',
145 WITH_THUMBNAILS = 'WITH_THUMBNAILS' 145 WITH_THUMBNAILS = 'WITH_THUMBNAILS',
146 WITH_LIVE = 'WITH_LIVE'
146} 147}
147 148
148export type ForAPIOptions = { 149export type ForAPIOptions = {
@@ -245,6 +246,14 @@ export type AvailableForListIDsOptions = {
245 } 246 }
246 ] 247 ]
247 }, 248 },
249 [ScopeNames.WITH_LIVE]: {
250 include: [
251 {
252 model: VideoLiveModel,
253 required: false
254 }
255 ]
256 },
248 [ScopeNames.WITH_USER_ID]: { 257 [ScopeNames.WITH_USER_ID]: {
249 include: [ 258 include: [
250 { 259 {
@@ -943,6 +952,17 @@ export class VideoModel extends Model<VideoModel> {
943 } 952 }
944 ] 953 ]
945 }, 954 },
955 {
956 model: VideoStreamingPlaylistModel.unscoped(),
957 required: false,
958 include: [
959 {
960 model: VideoFileModel,
961 required: false
962 }
963 ]
964 },
965 VideoLiveModel,
946 VideoFileModel, 966 VideoFileModel,
947 TagModel 967 TagModel
948 ] 968 ]
@@ -1330,7 +1350,8 @@ export class VideoModel extends Model<VideoModel> {
1330 ScopeNames.WITH_SCHEDULED_UPDATE, 1350 ScopeNames.WITH_SCHEDULED_UPDATE,
1331 ScopeNames.WITH_WEBTORRENT_FILES, 1351 ScopeNames.WITH_WEBTORRENT_FILES,
1332 ScopeNames.WITH_STREAMING_PLAYLISTS, 1352 ScopeNames.WITH_STREAMING_PLAYLISTS,
1333 ScopeNames.WITH_THUMBNAILS 1353 ScopeNames.WITH_THUMBNAILS,
1354 ScopeNames.WITH_LIVE
1334 ] 1355 ]
1335 1356
1336 if (userId) { 1357 if (userId) {
@@ -1362,6 +1383,7 @@ export class VideoModel extends Model<VideoModel> {
1362 ScopeNames.WITH_ACCOUNT_DETAILS, 1383 ScopeNames.WITH_ACCOUNT_DETAILS,
1363 ScopeNames.WITH_SCHEDULED_UPDATE, 1384 ScopeNames.WITH_SCHEDULED_UPDATE,
1364 ScopeNames.WITH_THUMBNAILS, 1385 ScopeNames.WITH_THUMBNAILS,
1386 ScopeNames.WITH_LIVE,
1365 { method: [ ScopeNames.WITH_WEBTORRENT_FILES, true ] }, 1387 { method: [ ScopeNames.WITH_WEBTORRENT_FILES, true ] },
1366 { method: [ ScopeNames.WITH_STREAMING_PLAYLISTS, true ] } 1388 { method: [ ScopeNames.WITH_STREAMING_PLAYLISTS, true ] }
1367 ] 1389 ]