diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-06-22 13:00:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 13:00:39 +0200 |
commit | 1ebddadd0704812a4600c39cabe2268321e88331 (patch) | |
tree | 1cc8560e5b63e9976aa5411ba800a62cfe7b8ea9 /client/src/app/shared/video/modals/video-report.component.ts | |
parent | 07aea1a2642fc9868cb01e30c322514029d5b95a (diff) | |
download | PeerTube-1ebddadd0704812a4600c39cabe2268321e88331.tar.gz PeerTube-1ebddadd0704812a4600c39cabe2268321e88331.tar.zst PeerTube-1ebddadd0704812a4600c39cabe2268321e88331.zip |
predefined report reasons & improved reporter UI (#2842)
- added `startAt` and `endAt` optional timestamps to help pin down reported sections of a video
- added predefined report reasons
- added video player with report modal
Diffstat (limited to 'client/src/app/shared/video/modals/video-report.component.ts')
-rw-r--r-- | client/src/app/shared/video/modals/video-report.component.ts | 104 |
1 files changed, 93 insertions, 11 deletions
diff --git a/client/src/app/shared/video/modals/video-report.component.ts b/client/src/app/shared/video/modals/video-report.component.ts index 988fa03d4..c2d441bba 100644 --- a/client/src/app/shared/video/modals/video-report.component.ts +++ b/client/src/app/shared/video/modals/video-report.component.ts | |||
@@ -8,6 +8,10 @@ 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 { VideoAbuseService } from '@app/shared/video-abuse' | 9 | import { VideoAbuseService } from '@app/shared/video-abuse' |
10 | import { Video } from '@app/shared/video/video.model' | 10 | import { Video } from '@app/shared/video/video.model' |
11 | import { buildVideoEmbed, buildVideoLink } from 'src/assets/player/utils' | ||
12 | import { DomSanitizer, SafeHtml } from '@angular/platform-browser' | ||
13 | import { VideoAbusePredefinedReasonsString, videoAbusePredefinedReasonsMap } from '@shared/models/videos/abuse/video-abuse-reason.model' | ||
14 | import { mapValues, pickBy } from 'lodash-es' | ||
11 | 15 | ||
12 | @Component({ | 16 | @Component({ |
13 | selector: 'my-video-report', | 17 | selector: 'my-video-report', |
@@ -20,6 +24,8 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
20 | @ViewChild('modal', { static: true }) modal: NgbModal | 24 | @ViewChild('modal', { static: true }) modal: NgbModal |
21 | 25 | ||
22 | error: string = null | 26 | error: string = null |
27 | predefinedReasons: { id: VideoAbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [] | ||
28 | embedHtml: SafeHtml | ||
23 | 29 | ||
24 | private openedModal: NgbModalRef | 30 | private openedModal: NgbModalRef |
25 | 31 | ||
@@ -29,6 +35,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
29 | private videoAbuseValidatorsService: VideoAbuseValidatorsService, | 35 | private videoAbuseValidatorsService: VideoAbuseValidatorsService, |
30 | private videoAbuseService: VideoAbuseService, | 36 | private videoAbuseService: VideoAbuseService, |
31 | private notifier: Notifier, | 37 | private notifier: Notifier, |
38 | private sanitizer: DomSanitizer, | ||
32 | private i18n: I18n | 39 | private i18n: I18n |
33 | ) { | 40 | ) { |
34 | super() | 41 | super() |
@@ -46,14 +53,82 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
46 | return '' | 53 | return '' |
47 | } | 54 | } |
48 | 55 | ||
56 | get timestamp () { | ||
57 | return this.form.get('timestamp').value | ||
58 | } | ||
59 | |||
60 | getVideoEmbed () { | ||
61 | return this.sanitizer.bypassSecurityTrustHtml( | ||
62 | buildVideoEmbed( | ||
63 | buildVideoLink({ | ||
64 | baseUrl: this.video.embedUrl, | ||
65 | title: false, | ||
66 | warningTitle: false | ||
67 | }) | ||
68 | ) | ||
69 | ) | ||
70 | } | ||
71 | |||
49 | ngOnInit () { | 72 | ngOnInit () { |
50 | this.buildForm({ | 73 | this.buildForm({ |
51 | reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON | 74 | reason: this.videoAbuseValidatorsService.VIDEO_ABUSE_REASON, |
75 | predefinedReasons: mapValues(videoAbusePredefinedReasonsMap, r => null), | ||
76 | timestamp: { | ||
77 | hasStart: null, | ||
78 | startAt: null, | ||
79 | hasEnd: null, | ||
80 | endAt: null | ||
81 | } | ||
52 | }) | 82 | }) |
83 | |||
84 | this.predefinedReasons = [ | ||
85 | { | ||
86 | id: 'violentOrRepulsive', | ||
87 | label: this.i18n('Violent or repulsive'), | ||
88 | help: this.i18n('Contains offensive, violent, or coarse language or iconography.') | ||
89 | }, | ||
90 | { | ||
91 | id: 'hatefulOrAbusive', | ||
92 | label: this.i18n('Hateful or abusive'), | ||
93 | help: this.i18n('Contains abusive, racist or sexist language or iconography.') | ||
94 | }, | ||
95 | { | ||
96 | id: 'spamOrMisleading', | ||
97 | label: this.i18n('Spam, ad or false news'), | ||
98 | help: this.i18n('Contains marketing, spam, purposefully deceitful news, or otherwise misleading thumbnail/text/tags. Please provide reputable sources to report hoaxes.') | ||
99 | }, | ||
100 | { | ||
101 | id: 'privacy', | ||
102 | label: this.i18n('Privacy breach or doxxing'), | ||
103 | help: this.i18n('Contains personal information that could be used to track, identify, contact or impersonate someone (e.g. name, address, phone number, email, or credit card details).') | ||
104 | }, | ||
105 | { | ||
106 | id: 'rights', | ||
107 | label: this.i18n('Intellectual property violation'), | ||
108 | help: this.i18n('Infringes my intellectual property or copyright, wrt. the regional rules with which the server must comply.') | ||
109 | }, | ||
110 | { | ||
111 | id: 'serverRules', | ||
112 | label: this.i18n('Breaks server rules'), | ||
113 | description: this.i18n('Anything not included in the above that breaks the terms of service, code of conduct, or general rules in place on the server.') | ||
114 | }, | ||
115 | { | ||
116 | id: 'thumbnails', | ||
117 | label: this.i18n('Thumbnails'), | ||
118 | help: this.i18n('The above can only be seen in thumbnails.') | ||
119 | }, | ||
120 | { | ||
121 | id: 'captions', | ||
122 | label: this.i18n('Captions'), | ||
123 | help: this.i18n('The above can only be seen in captions (please describe which).') | ||
124 | } | ||
125 | ] | ||
126 | |||
127 | this.embedHtml = this.getVideoEmbed() | ||
53 | } | 128 | } |
54 | 129 | ||
55 | show () { | 130 | show () { |
56 | this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false }) | 131 | this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false, size: 'lg' }) |
57 | } | 132 | } |
58 | 133 | ||
59 | hide () { | 134 | hide () { |
@@ -62,17 +137,24 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
62 | } | 137 | } |
63 | 138 | ||
64 | report () { | 139 | report () { |
65 | const reason = this.form.value['reason'] | 140 | const reason = this.form.get('reason').value |
141 | const predefinedReasons = Object.keys(pickBy(this.form.get('predefinedReasons').value)) as VideoAbusePredefinedReasonsString[] | ||
142 | const { hasStart, startAt, hasEnd, endAt } = this.form.get('timestamp').value | ||
66 | 143 | ||
67 | this.videoAbuseService.reportVideo(this.video.id, reason) | 144 | this.videoAbuseService.reportVideo({ |
68 | .subscribe( | 145 | id: this.video.id, |
69 | () => { | 146 | reason, |
70 | this.notifier.success(this.i18n('Video reported.')) | 147 | predefinedReasons, |
71 | this.hide() | 148 | startAt: hasStart && startAt ? startAt : undefined, |
72 | }, | 149 | endAt: hasEnd && endAt ? endAt : undefined |
150 | }).subscribe( | ||
151 | () => { | ||
152 | this.notifier.success(this.i18n('Video reported.')) | ||
153 | this.hide() | ||
154 | }, | ||
73 | 155 | ||
74 | err => this.notifier.error(err.message) | 156 | err => this.notifier.error(err.message) |
75 | ) | 157 | ) |
76 | } | 158 | } |
77 | 159 | ||
78 | isRemoteVideo () { | 160 | isRemoteVideo () { |