]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/video-live-replay-setting.ts
Prevent object storage mock conflicts
[github/Chocobozzz/PeerTube.git] / server / models / video / video-live-replay-setting.ts
CommitLineData
05a60d85
W
1import { isVideoPrivacyValid } from '@server/helpers/custom-validators/videos'
2import { MLiveReplaySetting } from '@server/types/models/video/video-live-replay-setting'
3import { VideoPrivacy } from '@shared/models/videos/video-privacy.enum'
4import { Transaction } from 'sequelize'
5import { AllowNull, Column, CreatedAt, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
6import { throwIfNotValid } from '../shared/sequelize-helpers'
7
8@Table({
9 tableName: 'videoLiveReplaySetting'
10})
11export class VideoLiveReplaySettingModel extends Model<VideoLiveReplaySettingModel> {
12
13 @CreatedAt
14 createdAt: Date
15
16 @UpdatedAt
17 updatedAt: Date
18
19 @AllowNull(false)
20 @Is('VideoPrivacy', value => throwIfNotValid(value, isVideoPrivacyValid, 'privacy'))
21 @Column
22 privacy: VideoPrivacy
23
24 static load (id: number, transaction?: Transaction): Promise<MLiveReplaySetting> {
25 return VideoLiveReplaySettingModel.findOne({
26 where: { id },
27 transaction
28 })
29 }
30
31 static removeSettings (id: number) {
32 return VideoLiveReplaySettingModel.destroy({
33 where: { id }
34 })
35 }
36
37 toFormattedJSON () {
38 return {
39 privacy: this.privacy
40 }
41 }
42}