-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, AttributesOnly } from '@shared/core-utils'
import {
AbuseFilter,
AbuseObject,
}
]
})
-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,