UpdatedAt
} from 'sequelize-typescript'
import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses'
-import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
+import { abusePredefinedReasonsMap } from '@shared/core-utils'
import {
AbuseFilter,
AbuseObject,
UserAbuse,
UserVideoAbuse
} from '@shared/models'
+import { AttributesOnly } from '@shared/typescript-utils'
import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { MAbuseAdminFormattable, MAbuseAP, MAbuseFull, MAbuseReporter, MAbuseUserFormattable, MUserAccountId } from '../../types/models'
import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account'
-import { getSort, throwIfNotValid } from '../utils'
+import { getSort, throwIfNotValid } from '../shared'
import { ThumbnailModel } from '../video/thumbnail'
import { ScopeNames as VideoScopeNames, VideoModel } from '../video/video'
import { VideoBlacklistModel } from '../video/video-blacklist'
import { ScopeNames as VideoChannelScopeNames, SummaryOptions as ChannelSummaryOptions, VideoChannelModel } from '../video/video-channel'
import { ScopeNames as CommentScopeNames, VideoCommentModel } from '../video/video-comment'
-import { buildAbuseListQuery, BuildAbusesQueryOptions } from './abuse-query-builder'
+import { buildAbuseListQuery, BuildAbusesQueryOptions } from './sql/abuse-query-builder'
import { VideoAbuseModel } from './video-abuse'
import { VideoCommentAbuseModel } from './video-comment-abuse'
}
]
})
-export class AbuseModel extends Model {
+export class AbuseModel extends Model<Partial<AttributesOnly<AbuseModel>>> {
@AllowNull(false)
@Default(null)
}
buildBaseVideoCommentAbuse (this: MAbuseUserFormattable) {
- if (!this.VideoCommentAbuse) return null
+ // Associated video comment could have been destroyed if the video has been deleted
+ if (!this.VideoCommentAbuse?.VideoComment) return null
- const abuseModel = this.VideoCommentAbuse
- const entity = abuseModel.VideoComment
+ const entity = this.VideoCommentAbuse.VideoComment
return {
id: entity.id,
return {
type: 'Flag' as 'Flag',
content: this.reason,
+ mediaType: 'text/markdown',
object,
tag: predefinedReasons.map(r => ({
type: 'Hashtag' as 'Hashtag',