PeerTube/server/core/models/abuse/video-abuse.ts

65 lines
1.2 KiB
TypeScript
Raw Normal View History

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