ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

video-live-replay-setting.ts 1.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { type VideoPrivacyType } from '@peertube/peertube-models'
  2. import { isVideoPrivacyValid } from '@server/helpers/custom-validators/videos.js'
  3. import { MLiveReplaySetting } from '@server/types/models/video/video-live-replay-setting.js'
  4. import { Transaction } from 'sequelize'
  5. import { AllowNull, Column, CreatedAt, Is, Table, UpdatedAt } from 'sequelize-typescript'
  6. import { throwIfNotValid } from '../shared/sequelize-helpers.js'
  7. import { SequelizeModel } from '../shared/index.js'
  8. @Table({
  9. tableName: 'videoLiveReplaySetting'
  10. })
  11. export class VideoLiveReplaySettingModel extends SequelizeModel<VideoLiveReplaySettingModel> {
  12. @CreatedAt
  13. createdAt: Date
  14. @UpdatedAt
  15. updatedAt: Date
  16. @AllowNull(false)
  17. @Is('VideoPrivacy', value => throwIfNotValid(value, isVideoPrivacyValid, 'privacy'))
  18. @Column
  19. privacy: VideoPrivacyType
  20. static load (id: number, transaction?: Transaction): Promise<MLiveReplaySetting> {
  21. return VideoLiveReplaySettingModel.findOne({
  22. where: { id },
  23. transaction
  24. })
  25. }
  26. static removeSettings (id: number) {
  27. return VideoLiveReplaySettingModel.destroy({
  28. where: { id }
  29. })
  30. }
  31. toFormattedJSON () {
  32. return {
  33. privacy: this.privacy
  34. }
  35. }
  36. }