aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-live-replay-setting.ts
diff options
context:
space:
mode:
authorWicklow <123956049+wickloww@users.noreply.github.com>2023-03-31 07:12:21 +0000
committerGitHub <noreply@github.com>2023-03-31 09:12:21 +0200
commit05a60d85997c108d39bcfb14f1ffd4c74f8b1e93 (patch)
tree5041a95ef945620a17f25ba934064b41f6bb00b7 /server/models/video/video-live-replay-setting.ts
parentebd61437c1ec92bea9772924c7051cb00d71f778 (diff)
downloadPeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.tar.gz
PeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.tar.zst
PeerTube-05a60d85997c108d39bcfb14f1ffd4c74f8b1e93.zip
Feature/Add replay privacy (#5692)
* Add replay settings feature * Fix replay settings behaviour * Fix tests * Fix tests * Fix tests * Update openapi doc and fix tests * Add tests and fix code * Models correction * Add migration and update controller and middleware * Add check params tests * Fix video live middleware * Updated code based on review comments
Diffstat (limited to 'server/models/video/video-live-replay-setting.ts')
-rw-r--r--server/models/video/video-live-replay-setting.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/server/models/video/video-live-replay-setting.ts b/server/models/video/video-live-replay-setting.ts
new file mode 100644
index 000000000..1c824dfa2
--- /dev/null
+++ b/server/models/video/video-live-replay-setting.ts
@@ -0,0 +1,42 @@
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}