PeerTube/server/core/models/video/video-live-replay-setting.ts

44 lines
1.2 KiB
TypeScript
Raw Normal View History

import { type VideoPrivacyType } from '@peertube/peertube-models'
import { isVideoPrivacyValid } from '@server/helpers/custom-validators/videos.js'
import { MLiveReplaySetting } from '@server/types/models/video/video-live-replay-setting.js'
import { Transaction } from 'sequelize'
2024-02-22 03:12:04 -06:00
import { AllowNull, Column, CreatedAt, Is, Table, UpdatedAt } from 'sequelize-typescript'
import { throwIfNotValid } from '../shared/sequelize-helpers.js'
2024-02-22 03:12:04 -06:00
import { SequelizeModel } from '../shared/index.js'
@Table({
tableName: 'videoLiveReplaySetting'
})
2024-02-22 03:12:04 -06:00
export class VideoLiveReplaySettingModel extends SequelizeModel<VideoLiveReplaySettingModel> {
@CreatedAt
createdAt: Date
@UpdatedAt
updatedAt: Date
@AllowNull(false)
@Is('VideoPrivacy', value => throwIfNotValid(value, isVideoPrivacyValid, 'privacy'))
@Column
privacy: VideoPrivacyType
static load (id: number, transaction?: Transaction): Promise<MLiveReplaySetting> {
return VideoLiveReplaySettingModel.findOne({
where: { id },
transaction
})
}
static removeSettings (id: number) {
return VideoLiveReplaySettingModel.destroy({
where: { id }
})
}
toFormattedJSON () {
return {
privacy: this.privacy
}
}
}