- const instanceMethods = [
- toFormattedJSON,
- toActivityPubObject
- ]
- addMethodsToModel(VideoAbuse, classMethods, instanceMethods)
-
- return VideoAbuse
-}
-
-// ------------------------------ METHODS ------------------------------
-
-toFormattedJSON = function (this: VideoAbuseInstance) {
- let reporterServerHost
-
- if (this.Account.Server) {
- reporterServerHost = this.Account.Server.host
- } else {
- // It means it's our video
- reporterServerHost = CONFIG.WEBSERVER.HOST
- }
-
- const json = {
- id: this.id,
- reason: this.reason,
- reporterUsername: this.Account.name,
- reporterServerHost,
- videoId: this.Video.id,
- videoUUID: this.Video.uuid,
- videoName: this.Video.name,
- createdAt: this.createdAt
- }
-
- return json
-}
-
-toActivityPubObject = function (this: VideoAbuseInstance) {
- const videoAbuseObject: VideoAbuseObject = {
- type: 'Flag' as 'Flag',
- content: this.reason,
- object: this.Video.url
- }
-
- return videoAbuseObject
-}
-
-// ------------------------------ STATICS ------------------------------
-
-function associate (models) {
- VideoAbuse.belongsTo(models.Account, {
+})
+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, {