diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-01 16:05:30 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-10 14:02:41 +0200 |
commit | d95d15598847c7f020aa056e7e6e0c02d2bbf732 (patch) | |
tree | a8a593f1269688caf9e5f99559996f346290fec5 /client/src/app/shared/shared-moderation/video-report.component.ts | |
parent | 72493e44e9b455a04c4f093ed6c6ffa300b98d8b (diff) | |
download | PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.tar.gz PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.tar.zst PeerTube-d95d15598847c7f020aa056e7e6e0c02d2bbf732.zip |
Use 3 tables to represent abuses
Diffstat (limited to 'client/src/app/shared/shared-moderation/video-report.component.ts')
-rw-r--r-- | client/src/app/shared/shared-moderation/video-report.component.ts | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/client/src/app/shared/shared-moderation/video-report.component.ts b/client/src/app/shared/shared-moderation/video-report.component.ts index 11c805636..b8d9f8d27 100644 --- a/client/src/app/shared/shared-moderation/video-report.component.ts +++ b/client/src/app/shared/shared-moderation/video-report.component.ts | |||
@@ -3,13 +3,13 @@ import { buildVideoEmbed, buildVideoLink } from 'src/assets/player/utils' | |||
3 | import { Component, Input, OnInit, ViewChild } from '@angular/core' | 3 | import { Component, Input, OnInit, ViewChild } from '@angular/core' |
4 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' | 4 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' |
5 | import { Notifier } from '@app/core' | 5 | import { Notifier } from '@app/core' |
6 | import { FormReactive, FormValidatorService, VideoAbuseValidatorsService } from '@app/shared/shared-forms' | 6 | import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' |
7 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 7 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
8 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | 8 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' |
9 | import { I18n } from '@ngx-translate/i18n-polyfill' | 9 | import { I18n } from '@ngx-translate/i18n-polyfill' |
10 | import { videoAbusePredefinedReasonsMap, VideoAbusePredefinedReasonsString } from '@shared/models/videos/abuse/video-abuse-reason.model' | 10 | import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' |
11 | import { Video } from '../shared-main' | 11 | import { Video } from '../shared-main' |
12 | import { VideoAbuseService } from './video-abuse.service' | 12 | import { AbuseService } from './abuse.service' |
13 | 13 | ||
14 | @Component({ | 14 | @Component({ |
15 | selector: 'my-video-report', | 15 | selector: 'my-video-report', |
@@ -22,7 +22,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
22 | @ViewChild('modal', { static: true }) modal: NgbModal | 22 | @ViewChild('modal', { static: true }) modal: NgbModal |
23 | 23 | ||
24 | error: string = null | 24 | error: string = null |
25 | predefinedReasons: { id: VideoAbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [] | 25 | predefinedReasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [] |
26 | embedHtml: SafeHtml | 26 | embedHtml: SafeHtml |
27 | 27 | ||
28 | private openedModal: NgbModalRef | 28 | private openedModal: NgbModalRef |
@@ -30,8 +30,8 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
30 | constructor ( | 30 | constructor ( |
31 | protected formValidatorService: FormValidatorService, | 31 | protected formValidatorService: FormValidatorService, |
32 | private modalService: NgbModal, | 32 | private modalService: NgbModal, |
33 | private videoAbuseValidatorsService: VideoAbuseValidatorsService, | 33 | private abuseValidatorsService: AbuseValidatorsService, |
34 | private videoAbuseService: VideoAbuseService, | 34 | private abuseService: AbuseService, |
35 | private notifier: Notifier, | 35 | private notifier: Notifier, |
36 | private sanitizer: DomSanitizer, | 36 | private sanitizer: DomSanitizer, |
37 | private i18n: I18n | 37 | private i18n: I18n |
@@ -69,8 +69,8 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
69 | 69 | ||
70 | ngOnInit () { | 70 | ngOnInit () { |
71 | this.buildForm({ | 71 | this.buildForm({ |
72 | reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON, | 72 | reason: this.abuseValidatorsService.ABUSE_REASON, |
73 | predefinedReasons: mapValues(videoAbusePredefinedReasonsMap, r => null), | 73 | predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null), |
74 | timestamp: { | 74 | timestamp: { |
75 | hasStart: null, | 75 | hasStart: null, |
76 | startAt: null, | 76 | startAt: null, |
@@ -136,15 +136,18 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
136 | 136 | ||
137 | report () { | 137 | report () { |
138 | const reason = this.form.get('reason').value | 138 | const reason = this.form.get('reason').value |
139 | const predefinedReasons = Object.keys(pickBy(this.form.get('predefinedReasons').value)) as VideoAbusePredefinedReasonsString[] | 139 | const predefinedReasons = Object.keys(pickBy(this.form.get('predefinedReasons').value)) as AbusePredefinedReasonsString[] |
140 | const { hasStart, startAt, hasEnd, endAt } = this.form.get('timestamp').value | 140 | const { hasStart, startAt, hasEnd, endAt } = this.form.get('timestamp').value |
141 | 141 | ||
142 | this.videoAbuseService.reportVideo({ | 142 | this.abuseService.reportVideo({ |
143 | id: this.video.id, | 143 | accountId: this.video.account.id, |
144 | reason, | 144 | reason, |
145 | predefinedReasons, | 145 | predefinedReasons, |
146 | startAt: hasStart && startAt ? startAt : undefined, | 146 | video: { |
147 | endAt: hasEnd && endAt ? endAt : undefined | 147 | id: this.video.id, |
148 | startAt: hasStart && startAt ? startAt : undefined, | ||
149 | endAt: hasEnd && endAt ? endAt : undefined | ||
150 | } | ||
148 | }).subscribe( | 151 | }).subscribe( |
149 | () => { | 152 | () => { |
150 | this.notifier.success(this.i18n('Video reported.')) | 153 | this.notifier.success(this.i18n('Video reported.')) |