-import * as Bluebird from 'bluebird'
import { invert } from 'lodash'
import { literal, Op, QueryTypes } from 'sequelize'
import {
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'
}
]
})
-export class AbuseModel extends Model<AbuseModel> {
+export class AbuseModel extends Model<Partial<AttributesOnly<AbuseModel>>> {
@AllowNull(false)
@Default(null)
})
VideoAbuse: VideoAbuseModel
- static loadByIdWithReporter (id: number): Bluebird<MAbuseReporter> {
+ static loadByIdWithReporter (id: number): Promise<MAbuseReporter> {
const query = {
where: {
id
return AbuseModel.findOne(query)
}
- static loadFull (id: number): Bluebird<MAbuseFull> {
+ static loadFull (id: number): Promise<MAbuseFull> {
const query = {
where: {
id
}
buildBaseVideoCommentAbuse (this: MAbuseUserFormattable) {
- if (!this.VideoCommentAbuse) return null
+ // Associated video comment could have been destroyed if the video has been deleted
+ if (!this.VideoCommentAbuse || !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',