]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-live.ts
Stricter models typing
[github/Chocobozzz/PeerTube.git] / server / models / video / video-live.ts
index 0e229de6ab0c946d7cb6c1015999c8e7610808ed..014491d50011f532de056c2e79e022d1276ce33c 100644 (file)
@@ -1,6 +1,7 @@
 import { AllowNull, BelongsTo, Column, CreatedAt, DataType, DefaultScope, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript'
 import { WEBSERVER } from '@server/initializers/constants'
 import { MVideoLive, MVideoLiveVideo } from '@server/types/models'
+import { AttributesOnly } from '@shared/core-utils'
 import { LiveVideo, VideoState } from '@shared/models'
 import { VideoModel } from './video'
 import { VideoBlacklistModel } from './video-blacklist'
@@ -28,7 +29,7 @@ import { VideoBlacklistModel } from './video-blacklist'
     }
   ]
 })
-export class VideoLiveModel extends Model<VideoLiveModel> {
+export class VideoLiveModel extends Model<Partial<AttributesOnly<VideoLiveModel>>> {
 
   @AllowNull(true)
   @Column(DataType.STRING)
@@ -38,6 +39,10 @@ export class VideoLiveModel extends Model<VideoLiveModel> {
   @Column
   saveReplay: boolean
 
+  @AllowNull(false)
+  @Column
+  permanentLive: boolean
+
   @CreatedAt
   createdAt: Date
 
@@ -93,8 +98,14 @@ export class VideoLiveModel extends Model<VideoLiveModel> {
 
   toFormattedJSON (): LiveVideo {
     return {
-      rtmpUrl: WEBSERVER.RTMP_URL,
-      streamKey: this.streamKey
+      // If we don't have a stream key, it means this is a remote live so we don't specify the rtmp URL
+      rtmpUrl: this.streamKey
+        ? WEBSERVER.RTMP_URL
+        : null,
+
+      streamKey: this.streamKey,
+      permanentLive: this.permanentLive,
+      saveReplay: this.saveReplay
     }
   }
 }