aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/abuse/abuse.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/abuse/abuse.ts')
-rw-r--r--server/models/abuse/abuse.ts26
1 files changed, 18 insertions, 8 deletions
diff --git a/server/models/abuse/abuse.ts b/server/models/abuse/abuse.ts
index 7002502d5..3353e9e41 100644
--- a/server/models/abuse/abuse.ts
+++ b/server/models/abuse/abuse.ts
@@ -25,14 +25,14 @@ import {
25 AbusePredefinedReasonsString, 25 AbusePredefinedReasonsString,
26 AbuseState, 26 AbuseState,
27 AbuseVideoIs, 27 AbuseVideoIs,
28 AdminVideoAbuse,
29 AdminAbuse, 28 AdminAbuse,
29 AdminVideoAbuse,
30 AdminVideoCommentAbuse, 30 AdminVideoCommentAbuse,
31 UserAbuse, 31 UserAbuse,
32 UserVideoAbuse 32 UserVideoAbuse
33} from '@shared/models' 33} from '@shared/models'
34import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' 34import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants'
35import { MAbuse, MAbuseAdminFormattable, MAbuseAP, MUserAccountId, MAbuseUserFormattable } from '../../types/models' 35import { MAbuse, MAbuseAdminFormattable, MAbuseAP, MAbuseReporter, MAbuseUserFormattable, MUserAccountId } from '../../types/models'
36import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' 36import { AccountModel, ScopeNames as AccountScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account'
37import { getSort, throwIfNotValid } from '../utils' 37import { getSort, throwIfNotValid } from '../utils'
38import { ThumbnailModel } from '../video/thumbnail' 38import { ThumbnailModel } from '../video/thumbnail'
@@ -266,7 +266,7 @@ export class AbuseModel extends Model<AbuseModel> {
266 VideoAbuse: VideoAbuseModel 266 VideoAbuse: VideoAbuseModel
267 267
268 // FIXME: deprecated in 2.3. Remove these validators 268 // FIXME: deprecated in 2.3. Remove these validators
269 static loadByIdAndVideoId (id: number, videoId?: number, uuid?: string): Bluebird<MAbuse> { 269 static loadByIdAndVideoId (id: number, videoId?: number, uuid?: string): Bluebird<MAbuseReporter> {
270 const videoWhere: WhereOptions = {} 270 const videoWhere: WhereOptions = {}
271 271
272 if (videoId) videoWhere.videoId = videoId 272 if (videoId) videoWhere.videoId = videoId
@@ -278,6 +278,10 @@ export class AbuseModel extends Model<AbuseModel> {
278 model: VideoAbuseModel, 278 model: VideoAbuseModel,
279 required: true, 279 required: true,
280 where: videoWhere 280 where: videoWhere
281 },
282 {
283 model: AccountModel,
284 as: 'ReporterAccount'
281 } 285 }
282 ], 286 ],
283 where: { 287 where: {
@@ -287,11 +291,17 @@ export class AbuseModel extends Model<AbuseModel> {
287 return AbuseModel.findOne(query) 291 return AbuseModel.findOne(query)
288 } 292 }
289 293
290 static loadById (id: number): Bluebird<MAbuse> { 294 static loadByIdWithReporter (id: number): Bluebird<MAbuseReporter> {
291 const query = { 295 const query = {
292 where: { 296 where: {
293 id 297 id
294 } 298 },
299 include: [
300 {
301 model: AccountModel,
302 as: 'ReporterAccount'
303 }
304 ]
295 } 305 }
296 306
297 return AbuseModel.findOne(query) 307 return AbuseModel.findOne(query)
@@ -466,8 +476,6 @@ export class AbuseModel extends Model<AbuseModel> {
466 label: AbuseModel.getStateLabel(this.state) 476 label: AbuseModel.getStateLabel(this.state)
467 }, 477 },
468 478
469 moderationComment: this.moderationComment,
470
471 countMessages, 479 countMessages,
472 480
473 createdAt: this.createdAt, 481 createdAt: this.createdAt,
@@ -500,6 +508,8 @@ export class AbuseModel extends Model<AbuseModel> {
500 video, 508 video,
501 comment, 509 comment,
502 510
511 moderationComment: this.moderationComment,
512
503 reporterAccount: this.ReporterAccount 513 reporterAccount: this.ReporterAccount
504 ? this.ReporterAccount.toFormattedJSON() 514 ? this.ReporterAccount.toFormattedJSON()
505 : null, 515 : null,
@@ -519,7 +529,7 @@ export class AbuseModel extends Model<AbuseModel> {
519 const countMessages = this.get('countMessages') as number 529 const countMessages = this.get('countMessages') as number
520 530
521 const video = this.buildBaseVideoAbuse() 531 const video = this.buildBaseVideoAbuse()
522 const comment: AdminVideoCommentAbuse = this.buildBaseVideoCommentAbuse() 532 const comment = this.buildBaseVideoCommentAbuse()
523 const abuse = this.buildBaseAbuse(countMessages || 0) 533 const abuse = this.buildBaseAbuse(countMessages || 0)
524 534
525 return Object.assign(abuse, { 535 return Object.assign(abuse, {