diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-09 15:54:24 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-10 14:02:41 +0200 |
commit | cfde28bac33c3644e1b6218eb471b675a37def60 (patch) | |
tree | eb648fc358a2face0f14c598c8eec7769e6b0ed5 /client/src/app/shared/shared-moderation | |
parent | 8ca56654a176ee8f350d31282c6cac4a59f58499 (diff) | |
download | PeerTube-cfde28bac33c3644e1b6218eb471b675a37def60.tar.gz PeerTube-cfde28bac33c3644e1b6218eb471b675a37def60.tar.zst PeerTube-cfde28bac33c3644e1b6218eb471b675a37def60.zip |
Add ability to report account
Diffstat (limited to 'client/src/app/shared/shared-moderation')
10 files changed, 125 insertions, 34 deletions
diff --git a/client/src/app/shared/shared-moderation/comment-report.component.scss b/client/src/app/shared/shared-moderation/comment-report.component.scss deleted file mode 100644 index 17a33d3a2..000000000 --- a/client/src/app/shared/shared-moderation/comment-report.component.scss +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | @import 'variables'; | ||
2 | @import 'mixins'; | ||
3 | |||
4 | .information { | ||
5 | margin-bottom: 20px; | ||
6 | } | ||
7 | |||
8 | textarea { | ||
9 | @include peertube-textarea(100%, 100px); | ||
10 | } | ||
11 | |||
diff --git a/client/src/app/shared/shared-moderation/index.ts b/client/src/app/shared/shared-moderation/index.ts index d6c4a10be..41c910ffe 100644 --- a/client/src/app/shared/shared-moderation/index.ts +++ b/client/src/app/shared/shared-moderation/index.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | export * from './report-modals' | ||
2 | |||
1 | export * from './abuse.service' | 3 | export * from './abuse.service' |
2 | export * from './account-block.model' | 4 | export * from './account-block.model' |
3 | export * from './account-blocklist.component' | 5 | export * from './account-blocklist.component' |
@@ -9,5 +11,4 @@ export * from './user-ban-modal.component' | |||
9 | export * from './user-moderation-dropdown.component' | 11 | export * from './user-moderation-dropdown.component' |
10 | export * from './video-block.component' | 12 | export * from './video-block.component' |
11 | export * from './video-block.service' | 13 | export * from './video-block.service' |
12 | export * from './video-report.component' | ||
13 | export * from './shared-moderation.module' | 14 | export * from './shared-moderation.module' |
diff --git a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts new file mode 100644 index 000000000..78ca934c7 --- /dev/null +++ b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts | |||
@@ -0,0 +1,94 @@ | |||
1 | import { mapValues, pickBy } from 'lodash-es' | ||
2 | import { Component, Input, OnInit, ViewChild } from '@angular/core' | ||
3 | import { Notifier } from '@app/core' | ||
4 | import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' | ||
5 | import { Account } from '@app/shared/shared-main' | ||
6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | ||
7 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | ||
8 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
9 | import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' | ||
10 | import { AbuseService } from '../abuse.service' | ||
11 | |||
12 | @Component({ | ||
13 | selector: 'my-account-report', | ||
14 | templateUrl: './report.component.html', | ||
15 | styleUrls: [ './report.component.scss' ] | ||
16 | }) | ||
17 | export class AccountReportComponent extends FormReactive implements OnInit { | ||
18 | @Input() account: Account = null | ||
19 | |||
20 | @ViewChild('modal', { static: true }) modal: NgbModal | ||
21 | |||
22 | error: string = null | ||
23 | predefinedReasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [] | ||
24 | modalTitle: string | ||
25 | |||
26 | private openedModal: NgbModalRef | ||
27 | |||
28 | constructor ( | ||
29 | protected formValidatorService: FormValidatorService, | ||
30 | private modalService: NgbModal, | ||
31 | private abuseValidatorsService: AbuseValidatorsService, | ||
32 | private abuseService: AbuseService, | ||
33 | private notifier: Notifier, | ||
34 | private i18n: I18n | ||
35 | ) { | ||
36 | super() | ||
37 | } | ||
38 | |||
39 | get currentHost () { | ||
40 | return window.location.host | ||
41 | } | ||
42 | |||
43 | get originHost () { | ||
44 | if (this.isRemote()) { | ||
45 | return this.account.host | ||
46 | } | ||
47 | |||
48 | return '' | ||
49 | } | ||
50 | |||
51 | ngOnInit () { | ||
52 | this.modalTitle = this.i18n('Report {{displayName}}', { displayName: this.account.displayName }) | ||
53 | |||
54 | this.buildForm({ | ||
55 | reason: this.abuseValidatorsService.ABUSE_REASON, | ||
56 | predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null) | ||
57 | }) | ||
58 | |||
59 | this.predefinedReasons = this.abuseService.getPrefefinedReasons('account') | ||
60 | } | ||
61 | |||
62 | show () { | ||
63 | this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false, size: 'lg' }) | ||
64 | } | ||
65 | |||
66 | hide () { | ||
67 | this.openedModal.close() | ||
68 | this.openedModal = null | ||
69 | } | ||
70 | |||
71 | report () { | ||
72 | const reason = this.form.get('reason').value | ||
73 | const predefinedReasons = Object.keys(pickBy(this.form.get('predefinedReasons').value)) as AbusePredefinedReasonsString[] | ||
74 | |||
75 | this.abuseService.reportVideo({ | ||
76 | reason, | ||
77 | predefinedReasons, | ||
78 | account: { | ||
79 | id: this.account.id | ||
80 | } | ||
81 | }).subscribe( | ||
82 | () => { | ||
83 | this.notifier.success(this.i18n('Account reported.')) | ||
84 | this.hide() | ||
85 | }, | ||
86 | |||
87 | err => this.notifier.error(err.message) | ||
88 | ) | ||
89 | } | ||
90 | |||
91 | isRemote () { | ||
92 | return !this.account.isLocal | ||
93 | } | ||
94 | } | ||
diff --git a/client/src/app/shared/shared-moderation/comment-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts index 5db4b2dc1..00d7b8d34 100644 --- a/client/src/app/shared/shared-moderation/comment-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts | |||
@@ -1,28 +1,27 @@ | |||
1 | import { mapValues, pickBy } from 'lodash-es' | 1 | import { mapValues, pickBy } from 'lodash-es' |
2 | import { Component, Input, OnInit, ViewChild } from '@angular/core' | 2 | import { Component, Input, OnInit, ViewChild } from '@angular/core' |
3 | import { SafeHtml } from '@angular/platform-browser' | ||
4 | import { VideoComment } from '@app/+videos/+video-watch/comment/video-comment.model' | ||
5 | import { Notifier } from '@app/core' | 3 | import { Notifier } from '@app/core' |
6 | import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' | 4 | import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' |
5 | import { VideoComment } from '@app/shared/shared-video-comment' | ||
7 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
8 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | 7 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' |
9 | import { I18n } from '@ngx-translate/i18n-polyfill' | 8 | import { I18n } from '@ngx-translate/i18n-polyfill' |
10 | import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' | 9 | import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' |
11 | import { AbuseService } from './abuse.service' | 10 | import { AbuseService } from '../abuse.service' |
12 | 11 | ||
13 | @Component({ | 12 | @Component({ |
14 | selector: 'my-comment-report', | 13 | selector: 'my-comment-report', |
15 | templateUrl: './comment-report.component.html', | 14 | templateUrl: './report.component.html', |
16 | styleUrls: [ './comment-report.component.scss' ] | 15 | styleUrls: [ './report.component.scss' ] |
17 | }) | 16 | }) |
18 | export class CommentReportComponent extends FormReactive implements OnInit { | 17 | export class CommentReportComponent extends FormReactive implements OnInit { |
19 | @Input() comment: VideoComment = null | 18 | @Input() comment: VideoComment = null |
20 | 19 | ||
21 | @ViewChild('modal', { static: true }) modal: NgbModal | 20 | @ViewChild('modal', { static: true }) modal: NgbModal |
22 | 21 | ||
22 | modalTitle: string | ||
23 | error: string = null | 23 | error: string = null |
24 | predefinedReasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [] | 24 | predefinedReasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [] |
25 | embedHtml: SafeHtml | ||
26 | 25 | ||
27 | private openedModal: NgbModalRef | 26 | private openedModal: NgbModalRef |
28 | 27 | ||
@@ -42,7 +41,7 @@ export class CommentReportComponent extends FormReactive implements OnInit { | |||
42 | } | 41 | } |
43 | 42 | ||
44 | get originHost () { | 43 | get originHost () { |
45 | if (this.isRemoteComment()) { | 44 | if (this.isRemote()) { |
46 | return this.comment.account.host | 45 | return this.comment.account.host |
47 | } | 46 | } |
48 | 47 | ||
@@ -50,6 +49,8 @@ export class CommentReportComponent extends FormReactive implements OnInit { | |||
50 | } | 49 | } |
51 | 50 | ||
52 | ngOnInit () { | 51 | ngOnInit () { |
52 | this.modalTitle = this.i18n('Report comment') | ||
53 | |||
53 | this.buildForm({ | 54 | this.buildForm({ |
54 | reason: this.abuseValidatorsService.ABUSE_REASON, | 55 | reason: this.abuseValidatorsService.ABUSE_REASON, |
55 | predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null) | 56 | predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null) |
@@ -87,7 +88,7 @@ export class CommentReportComponent extends FormReactive implements OnInit { | |||
87 | ) | 88 | ) |
88 | } | 89 | } |
89 | 90 | ||
90 | isRemoteComment () { | 91 | isRemote () { |
91 | return !this.comment.isLocal | 92 | return !this.comment.isLocal |
92 | } | 93 | } |
93 | } | 94 | } |
diff --git a/client/src/app/shared/shared-moderation/report-modals/index.ts b/client/src/app/shared/shared-moderation/report-modals/index.ts new file mode 100644 index 000000000..f3c4058ae --- /dev/null +++ b/client/src/app/shared/shared-moderation/report-modals/index.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './account-report.component' | ||
2 | export * from './comment-report.component' | ||
3 | export * from './video-report.component' | ||
diff --git a/client/src/app/shared/shared-moderation/comment-report.component.html b/client/src/app/shared/shared-moderation/report-modals/report.component.html index 1105b3788..bda62312f 100644 --- a/client/src/app/shared/shared-moderation/comment-report.component.html +++ b/client/src/app/shared/shared-moderation/report-modals/report.component.html | |||
@@ -1,6 +1,6 @@ | |||
1 | <ng-template #modal> | 1 | <ng-template #modal> |
2 | <div class="modal-header"> | 2 | <div class="modal-header"> |
3 | <h4 i18n class="modal-title">Report comment</h4> | 3 | <h4 class="modal-title">{{ modalTitle }}</h4> |
4 | <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon> | 4 | <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon> |
5 | </div> | 5 | </div> |
6 | 6 | ||
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | <div class="col-7"> | 35 | <div class="col-7"> |
36 | <div i18n class="information"> | 36 | <div i18n class="information"> |
37 | Your report will be sent to moderators of {{ currentHost }}<ng-container *ngIf="isRemoteComment()"> and will be forwarded to the comment origin ({{ originHost }}) too</ng-container>. | 37 | Your report will be sent to moderators of {{ currentHost }}<ng-container *ngIf="isRemote()"> and will be forwarded to the comment origin ({{ originHost }}) too</ng-container>. |
38 | </div> | 38 | </div> |
39 | 39 | ||
40 | <div class="form-group"> | 40 | <div class="form-group"> |
diff --git a/client/src/app/shared/shared-moderation/video-report.component.scss b/client/src/app/shared/shared-moderation/report-modals/report.component.scss index b2606cbd8..b2606cbd8 100644 --- a/client/src/app/shared/shared-moderation/video-report.component.scss +++ b/client/src/app/shared/shared-moderation/report-modals/report.component.scss | |||
diff --git a/client/src/app/shared/shared-moderation/video-report.component.html b/client/src/app/shared/shared-moderation/report-modals/video-report.component.html index b724ecb18..4947088d1 100644 --- a/client/src/app/shared/shared-moderation/video-report.component.html +++ b/client/src/app/shared/shared-moderation/report-modals/video-report.component.html | |||
@@ -72,7 +72,7 @@ | |||
72 | </div> | 72 | </div> |
73 | 73 | ||
74 | <div i18n class="information"> | 74 | <div i18n class="information"> |
75 | Your report will be sent to moderators of {{ currentHost }}<ng-container *ngIf="isRemoteVideo()"> and will be forwarded to the video origin ({{ originHost }}) too</ng-container>. | 75 | Your report will be sent to moderators of {{ currentHost }}<ng-container *ngIf="isRemote()"> and will be forwarded to the video origin ({{ originHost }}) too</ng-container>. |
76 | </div> | 76 | </div> |
77 | 77 | ||
78 | <div class="form-group"> | 78 | <div class="form-group"> |
diff --git a/client/src/app/shared/shared-moderation/video-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts index 26e7b62ba..7d53ea3c9 100644 --- a/client/src/app/shared/shared-moderation/video-report.component.ts +++ b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts | |||
@@ -8,13 +8,13 @@ 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 { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' | 10 | import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' |
11 | import { Video } from '../shared-main' | 11 | import { Video } from '../../shared-main' |
12 | import { AbuseService } from './abuse.service' | 12 | import { AbuseService } from '../abuse.service' |
13 | 13 | ||
14 | @Component({ | 14 | @Component({ |
15 | selector: 'my-video-report', | 15 | selector: 'my-video-report', |
16 | templateUrl: './video-report.component.html', | 16 | templateUrl: './video-report.component.html', |
17 | styleUrls: [ './video-report.component.scss' ] | 17 | styleUrls: [ './report.component.scss' ] |
18 | }) | 18 | }) |
19 | export class VideoReportComponent extends FormReactive implements OnInit { | 19 | export class VideoReportComponent extends FormReactive implements OnInit { |
20 | @Input() video: Video = null | 20 | @Input() video: Video = null |
@@ -44,7 +44,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
44 | } | 44 | } |
45 | 45 | ||
46 | get originHost () { | 46 | get originHost () { |
47 | if (this.isRemoteVideo()) { | 47 | if (this.isRemote()) { |
48 | return this.video.account.host | 48 | return this.video.account.host |
49 | } | 49 | } |
50 | 50 | ||
@@ -116,7 +116,7 @@ export class VideoReportComponent extends FormReactive implements OnInit { | |||
116 | ) | 116 | ) |
117 | } | 117 | } |
118 | 118 | ||
119 | isRemoteVideo () { | 119 | isRemote () { |
120 | return !this.video.isLocal | 120 | return !this.video.isLocal |
121 | } | 121 | } |
122 | } | 122 | } |
diff --git a/client/src/app/shared/shared-moderation/shared-moderation.module.ts b/client/src/app/shared/shared-moderation/shared-moderation.module.ts index ff4021a33..8fa9ee794 100644 --- a/client/src/app/shared/shared-moderation/shared-moderation.module.ts +++ b/client/src/app/shared/shared-moderation/shared-moderation.module.ts | |||
@@ -3,22 +3,23 @@ import { NgModule } from '@angular/core' | |||
3 | import { SharedFormModule } from '../shared-forms/shared-form.module' | 3 | import { SharedFormModule } from '../shared-forms/shared-form.module' |
4 | import { SharedGlobalIconModule } from '../shared-icons' | 4 | import { SharedGlobalIconModule } from '../shared-icons' |
5 | import { SharedMainModule } from '../shared-main/shared-main.module' | 5 | import { SharedMainModule } from '../shared-main/shared-main.module' |
6 | import { SharedVideoCommentModule } from '../shared-video-comment' | ||
7 | import { AbuseService } from './abuse.service' | ||
6 | import { BatchDomainsModalComponent } from './batch-domains-modal.component' | 8 | import { BatchDomainsModalComponent } from './batch-domains-modal.component' |
7 | import { BlocklistService } from './blocklist.service' | 9 | import { BlocklistService } from './blocklist.service' |
8 | import { BulkService } from './bulk.service' | 10 | import { BulkService } from './bulk.service' |
9 | import { UserBanModalComponent } from './user-ban-modal.component' | 11 | import { UserBanModalComponent } from './user-ban-modal.component' |
10 | import { UserModerationDropdownComponent } from './user-moderation-dropdown.component' | 12 | import { UserModerationDropdownComponent } from './user-moderation-dropdown.component' |
11 | import { AbuseService } from './abuse.service' | ||
12 | import { VideoBlockComponent } from './video-block.component' | 13 | import { VideoBlockComponent } from './video-block.component' |
13 | import { VideoBlockService } from './video-block.service' | 14 | import { VideoBlockService } from './video-block.service' |
14 | import { VideoReportComponent } from './video-report.component' | 15 | import { VideoReportComponent, AccountReportComponent, CommentReportComponent } from './report-modals' |
15 | import { CommentReportComponent } from './comment-report.component' | ||
16 | 16 | ||
17 | @NgModule({ | 17 | @NgModule({ |
18 | imports: [ | 18 | imports: [ |
19 | SharedMainModule, | 19 | SharedMainModule, |
20 | SharedFormModule, | 20 | SharedFormModule, |
21 | SharedGlobalIconModule | 21 | SharedGlobalIconModule, |
22 | SharedVideoCommentModule | ||
22 | ], | 23 | ], |
23 | 24 | ||
24 | declarations: [ | 25 | declarations: [ |
@@ -27,7 +28,8 @@ import { CommentReportComponent } from './comment-report.component' | |||
27 | VideoBlockComponent, | 28 | VideoBlockComponent, |
28 | VideoReportComponent, | 29 | VideoReportComponent, |
29 | BatchDomainsModalComponent, | 30 | BatchDomainsModalComponent, |
30 | CommentReportComponent | 31 | CommentReportComponent, |
32 | AccountReportComponent | ||
31 | ], | 33 | ], |
32 | 34 | ||
33 | exports: [ | 35 | exports: [ |
@@ -36,7 +38,8 @@ import { CommentReportComponent } from './comment-report.component' | |||
36 | VideoBlockComponent, | 38 | VideoBlockComponent, |
37 | VideoReportComponent, | 39 | VideoReportComponent, |
38 | BatchDomainsModalComponent, | 40 | BatchDomainsModalComponent, |
39 | CommentReportComponent | 41 | CommentReportComponent, |
42 | AccountReportComponent | ||
40 | ], | 43 | ], |
41 | 44 | ||
42 | providers: [ | 45 | providers: [ |