aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-moderation/abuse.service.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-07-09 11:58:46 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-07-10 14:02:41 +0200
commit8ca56654a176ee8f350d31282c6cac4a59f58499 (patch)
tree6e52ed0d8410abfceb62bcb6230b8ed50bd6c574 /client/src/app/shared/shared-moderation/abuse.service.ts
parent310b5219b38427f0c2c7ba57225afdd8f3064380 (diff)
downloadPeerTube-8ca56654a176ee8f350d31282c6cac4a59f58499.tar.gz
PeerTube-8ca56654a176ee8f350d31282c6cac4a59f58499.tar.zst
PeerTube-8ca56654a176ee8f350d31282c6cac4a59f58499.zip
Add ability to report comments in front end
Diffstat (limited to 'client/src/app/shared/shared-moderation/abuse.service.ts')
-rw-r--r--client/src/app/shared/shared-moderation/abuse.service.ts96
1 files changed, 76 insertions, 20 deletions
diff --git a/client/src/app/shared/shared-moderation/abuse.service.ts b/client/src/app/shared/shared-moderation/abuse.service.ts
index f45018d5c..95ac16955 100644
--- a/client/src/app/shared/shared-moderation/abuse.service.ts
+++ b/client/src/app/shared/shared-moderation/abuse.service.ts
@@ -5,18 +5,20 @@ import { catchError, map } from 'rxjs/operators'
5import { HttpClient, HttpParams } from '@angular/common/http' 5import { HttpClient, HttpParams } from '@angular/common/http'
6import { Injectable } from '@angular/core' 6import { Injectable } from '@angular/core'
7import { RestExtractor, RestPagination, RestService } from '@app/core' 7import { RestExtractor, RestPagination, RestService } from '@app/core'
8import { AbuseUpdate, ResultList, Abuse, AbuseCreate, AbuseState } from '@shared/models' 8import { Abuse, AbuseCreate, AbuseFilter, AbusePredefinedReasonsString, AbuseState, AbuseUpdate, ResultList } from '@shared/models'
9import { environment } from '../../../environments/environment' 9import { environment } from '../../../environments/environment'
10import { I18n } from '@ngx-translate/i18n-polyfill'
10 11
11@Injectable() 12@Injectable()
12export class AbuseService { 13export class AbuseService {
13 private static BASE_ABUSE_URL = environment.apiUrl + '/api/v1/abuses' 14 private static BASE_ABUSE_URL = environment.apiUrl + '/api/v1/abuses'
14 15
15 constructor ( 16 constructor (
17 private i18n: I18n,
16 private authHttp: HttpClient, 18 private authHttp: HttpClient,
17 private restService: RestService, 19 private restService: RestService,
18 private restExtractor: RestExtractor 20 private restExtractor: RestExtractor
19 ) {} 21 ) { }
20 22
21 getAbuses (options: { 23 getAbuses (options: {
22 pagination: RestPagination, 24 pagination: RestPagination,
@@ -24,7 +26,7 @@ export class AbuseService {
24 search?: string 26 search?: string
25 }): Observable<ResultList<Abuse>> { 27 }): Observable<ResultList<Abuse>> {
26 const { pagination, sort, search } = options 28 const { pagination, sort, search } = options
27 const url = AbuseService.BASE_ABUSE_URL + 'abuse' 29 const url = AbuseService.BASE_ABUSE_URL
28 30
29 let params = new HttpParams() 31 let params = new HttpParams()
30 params = this.restService.addRestGetParams(params, pagination, sort) 32 params = this.restService.addRestGetParams(params, pagination, sort)
@@ -60,39 +62,93 @@ export class AbuseService {
60 } 62 }
61 63
62 return this.authHttp.get<ResultList<Abuse>>(url, { params }) 64 return this.authHttp.get<ResultList<Abuse>>(url, { params })
63 .pipe( 65 .pipe(
64 catchError(res => this.restExtractor.handleError(res)) 66 catchError(res => this.restExtractor.handleError(res))
65 ) 67 )
66 } 68 }
67 69
68 reportVideo (parameters: AbuseCreate) { 70 reportVideo (parameters: AbuseCreate) {
69 const url = AbuseService.BASE_ABUSE_URL 71 const url = AbuseService.BASE_ABUSE_URL
70 72
71 const body = omit(parameters, [ 'id' ]) 73 const body = omit(parameters, ['id'])
72 74
73 return this.authHttp.post(url, body) 75 return this.authHttp.post(url, body)
74 .pipe( 76 .pipe(
75 map(this.restExtractor.extractDataBool), 77 map(this.restExtractor.extractDataBool),
76 catchError(res => this.restExtractor.handleError(res)) 78 catchError(res => this.restExtractor.handleError(res))
77 ) 79 )
78 } 80 }
79 81
80 updateAbuse (abuse: Abuse, abuseUpdate: AbuseUpdate) { 82 updateAbuse (abuse: Abuse, abuseUpdate: AbuseUpdate) {
81 const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id 83 const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id
82 84
83 return this.authHttp.put(url, abuseUpdate) 85 return this.authHttp.put(url, abuseUpdate)
84 .pipe( 86 .pipe(
85 map(this.restExtractor.extractDataBool), 87 map(this.restExtractor.extractDataBool),
86 catchError(res => this.restExtractor.handleError(res)) 88 catchError(res => this.restExtractor.handleError(res))
87 ) 89 )
88 } 90 }
89 91
90 removeAbuse (abuse: Abuse) { 92 removeAbuse (abuse: Abuse) {
91 const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id 93 const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id
92 94
93 return this.authHttp.delete(url) 95 return this.authHttp.delete(url)
94 .pipe( 96 .pipe(
95 map(this.restExtractor.extractDataBool), 97 map(this.restExtractor.extractDataBool),
96 catchError(res => this.restExtractor.handleError(res)) 98 catchError(res => this.restExtractor.handleError(res))
97 ) 99 )
98 }} 100 }
101
102 getPrefefinedReasons (type: AbuseFilter) {
103 let reasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [
104 {
105 id: 'violentOrRepulsive',
106 label: this.i18n('Violent or repulsive'),
107 help: this.i18n('Contains offensive, violent, or coarse language or iconography.')
108 },
109 {
110 id: 'hatefulOrAbusive',
111 label: this.i18n('Hateful or abusive'),
112 help: this.i18n('Contains abusive, racist or sexist language or iconography.')
113 },
114 {
115 id: 'spamOrMisleading',
116 label: this.i18n('Spam, ad or false news'),
117 help: this.i18n('Contains marketing, spam, purposefully deceitful news, or otherwise misleading thumbnail/text/tags. Please provide reputable sources to report hoaxes.')
118 },
119 {
120 id: 'privacy',
121 label: this.i18n('Privacy breach or doxxing'),
122 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).')
123 },
124 {
125 id: 'rights',
126 label: this.i18n('Intellectual property violation'),
127 help: this.i18n('Infringes my intellectual property or copyright, wrt. the regional rules with which the server must comply.')
128 },
129 {
130 id: 'serverRules',
131 label: this.i18n('Breaks server rules'),
132 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.')
133 }
134 ]
135
136 if (type === 'video') {
137 reasons = reasons.concat([
138 {
139 id: 'thumbnails',
140 label: this.i18n('Thumbnails'),
141 help: this.i18n('The above can only be seen in thumbnails.')
142 },
143 {
144 id: 'captions',
145 label: this.i18n('Captions'),
146 help: this.i18n('The above can only be seen in captions (please describe which).')
147 }
148 ])
149 }
150
151 return reasons
152 }
153
154}