diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-08 15:51:46 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-10 14:02:41 +0200 |
commit | 310b5219b38427f0c2c7ba57225afdd8f3064380 (patch) | |
tree | 853ff7e4e66425ca47b0999384eeb08ed14b28ff /server/models/abuse | |
parent | 811cef146c841ef8530bc812c05dfee77e0f2998 (diff) | |
download | PeerTube-310b5219b38427f0c2c7ba57225afdd8f3064380.tar.gz PeerTube-310b5219b38427f0c2c7ba57225afdd8f3064380.tar.zst PeerTube-310b5219b38427f0c2c7ba57225afdd8f3064380.zip |
Add new abuses tests
Diffstat (limited to 'server/models/abuse')
-rw-r--r-- | server/models/abuse/abuse.ts | 10 | ||||
-rw-r--r-- | server/models/abuse/video-comment-abuse.ts | 8 |
2 files changed, 6 insertions, 12 deletions
diff --git a/server/models/abuse/abuse.ts b/server/models/abuse/abuse.ts index 28ecf8253..dffd503b3 100644 --- a/server/models/abuse/abuse.ts +++ b/server/models/abuse/abuse.ts | |||
@@ -362,8 +362,8 @@ export class AbuseModel extends Model<AbuseModel> { | |||
362 | const countReportsForReporter = this.get('countReportsForReporter') as number | 362 | const countReportsForReporter = this.get('countReportsForReporter') as number |
363 | const countReportsForReportee = this.get('countReportsForReportee') as number | 363 | const countReportsForReportee = this.get('countReportsForReportee') as number |
364 | 364 | ||
365 | let video: VideoAbuse | 365 | let video: VideoAbuse = null |
366 | let comment: VideoCommentAbuse | 366 | let comment: VideoCommentAbuse = null |
367 | 367 | ||
368 | if (this.VideoAbuse) { | 368 | if (this.VideoAbuse) { |
369 | const abuseModel = this.VideoAbuse | 369 | const abuseModel = this.VideoAbuse |
@@ -391,13 +391,13 @@ export class AbuseModel extends Model<AbuseModel> { | |||
391 | 391 | ||
392 | if (this.VideoCommentAbuse) { | 392 | if (this.VideoCommentAbuse) { |
393 | const abuseModel = this.VideoCommentAbuse | 393 | const abuseModel = this.VideoCommentAbuse |
394 | const entity = abuseModel.VideoComment || abuseModel.deletedComment | 394 | const entity = abuseModel.VideoComment |
395 | 395 | ||
396 | comment = { | 396 | comment = { |
397 | id: entity.id, | 397 | id: entity.id, |
398 | text: entity.text, | 398 | text: entity.text ?? '', |
399 | 399 | ||
400 | deleted: !abuseModel.VideoComment, | 400 | deleted: entity.isDeleted(), |
401 | 401 | ||
402 | video: { | 402 | video: { |
403 | id: entity.Video.id, | 403 | id: entity.Video.id, |
diff --git a/server/models/abuse/video-comment-abuse.ts b/server/models/abuse/video-comment-abuse.ts index de9f4d5fd..8b34009b4 100644 --- a/server/models/abuse/video-comment-abuse.ts +++ b/server/models/abuse/video-comment-abuse.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' | 1 | import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' |
2 | import { VideoComment } from '@shared/models' | ||
3 | import { VideoCommentModel } from '../video/video-comment' | 2 | import { VideoCommentModel } from '../video/video-comment' |
4 | import { AbuseModel } from './abuse' | 3 | import { AbuseModel } from './abuse' |
5 | 4 | ||
@@ -22,11 +21,6 @@ export class VideoCommentAbuseModel extends Model<VideoCommentAbuseModel> { | |||
22 | @UpdatedAt | 21 | @UpdatedAt |
23 | updatedAt: Date | 22 | updatedAt: Date |
24 | 23 | ||
25 | @AllowNull(true) | ||
26 | @Default(null) | ||
27 | @Column(DataType.JSONB) | ||
28 | deletedComment: VideoComment & { Video: { name: string, id: number, uuid: string }} | ||
29 | |||
30 | @ForeignKey(() => AbuseModel) | 24 | @ForeignKey(() => AbuseModel) |
31 | @Column | 25 | @Column |
32 | abuseId: number | 26 | abuseId: number |