Files
PeerTube/server/core/models/abuse/video-abuse.ts
Chocobozzz 13bceb5f40 Better thumbnail error handling
* Had to upgrade to es2022 to use `cause` error
 * Had to declare class attributes with declare for sequelize models, so
   it still works as before
2025-07-25 17:01:36 +02:00

64 lines
1.3 KiB
TypeScript

import { type VideoDetails } from '@peertube/peertube-models'
import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Table, UpdatedAt } from 'sequelize-typescript'
import { VideoModel } from '../video/video.js'
import { AbuseModel } from './abuse.js'
import { SequelizeModel } from '../shared/index.js'
@Table({
tableName: 'videoAbuse',
indexes: [
{
fields: [ 'abuseId' ]
},
{
fields: [ 'videoId' ]
}
]
})
export class VideoAbuseModel extends SequelizeModel<VideoAbuseModel> {
@CreatedAt
declare createdAt: Date
@UpdatedAt
declare updatedAt: Date
@AllowNull(true)
@Default(null)
@Column
declare startAt: number
@AllowNull(true)
@Default(null)
@Column
declare endAt: number
@AllowNull(true)
@Default(null)
@Column(DataType.JSONB)
declare deletedVideo: VideoDetails
@ForeignKey(() => AbuseModel)
@Column
declare abuseId: number
@BelongsTo(() => AbuseModel, {
foreignKey: {
allowNull: false
},
onDelete: 'cascade'
})
declare Abuse: Awaited<AbuseModel>
@ForeignKey(() => VideoModel)
@Column
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
allowNull: true
},
onDelete: 'set null'
})
declare Video: Awaited<VideoModel>
}