+ isVideoAbuseModerationCommentValid,
+ isVideoAbuseReasonValid,
+ isVideoAbuseStateValid
+} from '../../helpers/custom-validators/video-abuses'
+import { AccountModel } from '../account/account'
+import { getSort, throwIfNotValid } from '../utils'
+import { VideoModel } from './video'
+import { VideoAbuseState } from '../../../shared'
+import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers'
+
+@Table({
+ tableName: 'videoAbuse',
+ indexes: [
+ {
+ fields: [ 'videoId' ]
+ },
+ {
+ fields: [ 'reporterAccountId' ]
+ }
+ ]
+})
+export class VideoAbuseModel extends Model<VideoAbuseModel> {
+
+ @AllowNull(false)
+ @Default(null)
+ @Is('VideoAbuseReason', value => throwIfNotValid(value, isVideoAbuseReasonValid, 'reason'))
+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_ABUSES.REASON.max))
+ reason: string
+
+ @AllowNull(false)
+ @Default(null)
+ @Is('VideoAbuseState', value => throwIfNotValid(value, isVideoAbuseStateValid, 'state'))
+ @Column
+ state: VideoAbuseState
+
+ @AllowNull(true)
+ @Default(null)
+ @Is('VideoAbuseModerationComment', value => throwIfNotValid(value, isVideoAbuseModerationCommentValid, 'moderationComment'))
+ @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_ABUSES.MODERATION_COMMENT.max))
+ moderationComment: string
+
+ @CreatedAt
+ createdAt: Date
+
+ @UpdatedAt
+ updatedAt: Date
+
+ @ForeignKey(() => AccountModel)
+ @Column
+ reporterAccountId: number
+
+ @BelongsTo(() => AccountModel, {
+ foreignKey: {
+ allowNull: false
+ },
+ onDelete: 'cascade'
+ })
+ Account: AccountModel