- addMethodsToModel(VideoAbuse, classMethods, instanceMethods)
-
- return VideoAbuse
-}
-
-// ------------------------------ METHODS ------------------------------
-
-function toFormatedJSON (this: VideoAbuseInstance) {
- let reporterPodHost
-
- if (this.Pod) {
- reporterPodHost = this.Pod.host
- } else {
- // It means it's our video
- reporterPodHost = CONFIG.WEBSERVER.HOST
- }
-
- const json = {
- id: this.id,
- reporterPodHost,
- reason: this.reason,
- reporterUsername: this.reporterUsername,
- videoId: this.videoId,
- createdAt: this.createdAt
- }
-
- return json
-}
-
-// ------------------------------ STATICS ------------------------------
-
-function associate (models) {
- VideoAbuse.belongsTo(models.Pod, {
+})
+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', true))
+ @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, {