diff options
Diffstat (limited to 'client/src/app/shared/shared-moderation/abuse.service.ts')
-rw-r--r-- | client/src/app/shared/shared-moderation/abuse.service.ts | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/client/src/app/shared/shared-moderation/abuse.service.ts b/client/src/app/shared/shared-moderation/abuse.service.ts index 95ac16955..652d8370f 100644 --- a/client/src/app/shared/shared-moderation/abuse.service.ts +++ b/client/src/app/shared/shared-moderation/abuse.service.ts | |||
@@ -5,7 +5,7 @@ import { catchError, map } from 'rxjs/operators' | |||
5 | import { HttpClient, HttpParams } from '@angular/common/http' | 5 | import { HttpClient, HttpParams } from '@angular/common/http' |
6 | import { Injectable } from '@angular/core' | 6 | import { Injectable } from '@angular/core' |
7 | import { RestExtractor, RestPagination, RestService } from '@app/core' | 7 | import { RestExtractor, RestPagination, RestService } from '@app/core' |
8 | import { Abuse, AbuseCreate, AbuseFilter, AbusePredefinedReasonsString, AbuseState, AbuseUpdate, ResultList } from '@shared/models' | 8 | import { AdminAbuse, AbuseCreate, AbuseFilter, AbusePredefinedReasonsString, AbuseState, AbuseUpdate, ResultList, UserAbuse, AbuseMessage } from '@shared/models' |
9 | import { environment } from '../../../environments/environment' | 9 | import { environment } from '../../../environments/environment' |
10 | import { I18n } from '@ngx-translate/i18n-polyfill' | 10 | import { I18n } from '@ngx-translate/i18n-polyfill' |
11 | 11 | ||
@@ -20,11 +20,11 @@ export class AbuseService { | |||
20 | private restExtractor: RestExtractor | 20 | private restExtractor: RestExtractor |
21 | ) { } | 21 | ) { } |
22 | 22 | ||
23 | getAbuses (options: { | 23 | getAdminAbuses (options: { |
24 | pagination: RestPagination, | 24 | pagination: RestPagination, |
25 | sort: SortMeta, | 25 | sort: SortMeta, |
26 | search?: string | 26 | search?: string |
27 | }): Observable<ResultList<Abuse>> { | 27 | }): Observable<ResultList<AdminAbuse>> { |
28 | const { pagination, sort, search } = options | 28 | const { pagination, sort, search } = options |
29 | const url = AbuseService.BASE_ABUSE_URL | 29 | const url = AbuseService.BASE_ABUSE_URL |
30 | 30 | ||
@@ -61,7 +61,7 @@ export class AbuseService { | |||
61 | params = this.restService.addObjectParams(params, filters) | 61 | params = this.restService.addObjectParams(params, filters) |
62 | } | 62 | } |
63 | 63 | ||
64 | return this.authHttp.get<ResultList<Abuse>>(url, { params }) | 64 | return this.authHttp.get<ResultList<AdminAbuse>>(url, { params }) |
65 | .pipe( | 65 | .pipe( |
66 | catchError(res => this.restExtractor.handleError(res)) | 66 | catchError(res => this.restExtractor.handleError(res)) |
67 | ) | 67 | ) |
@@ -79,7 +79,7 @@ export class AbuseService { | |||
79 | ) | 79 | ) |
80 | } | 80 | } |
81 | 81 | ||
82 | updateAbuse (abuse: Abuse, abuseUpdate: AbuseUpdate) { | 82 | updateAbuse (abuse: AdminAbuse, abuseUpdate: AbuseUpdate) { |
83 | const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id | 83 | const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id |
84 | 84 | ||
85 | return this.authHttp.put(url, abuseUpdate) | 85 | return this.authHttp.put(url, abuseUpdate) |
@@ -89,7 +89,7 @@ export class AbuseService { | |||
89 | ) | 89 | ) |
90 | } | 90 | } |
91 | 91 | ||
92 | removeAbuse (abuse: Abuse) { | 92 | removeAbuse (abuse: AdminAbuse) { |
93 | const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id | 93 | const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id |
94 | 94 | ||
95 | return this.authHttp.delete(url) | 95 | return this.authHttp.delete(url) |
@@ -99,6 +99,35 @@ export class AbuseService { | |||
99 | ) | 99 | ) |
100 | } | 100 | } |
101 | 101 | ||
102 | addAbuseMessage (abuse: UserAbuse, message: string) { | ||
103 | const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id + '/messages' | ||
104 | |||
105 | return this.authHttp.post(url, { message }) | ||
106 | .pipe( | ||
107 | map(this.restExtractor.extractDataBool), | ||
108 | catchError(res => this.restExtractor.handleError(res)) | ||
109 | ) | ||
110 | } | ||
111 | |||
112 | listAbuseMessages (abuse: UserAbuse) { | ||
113 | const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id + '/messages' | ||
114 | |||
115 | return this.authHttp.get<ResultList<AbuseMessage>>(url) | ||
116 | .pipe( | ||
117 | catchError(res => this.restExtractor.handleError(res)) | ||
118 | ) | ||
119 | } | ||
120 | |||
121 | deleteAbuseMessage (abuse: UserAbuse, abuseMessage: AbuseMessage) { | ||
122 | const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id + '/messages/' + abuseMessage.id | ||
123 | |||
124 | return this.authHttp.delete(url) | ||
125 | .pipe( | ||
126 | map(this.restExtractor.extractDataBool), | ||
127 | catchError(res => this.restExtractor.handleError(res)) | ||
128 | ) | ||
129 | } | ||
130 | |||
102 | getPrefefinedReasons (type: AbuseFilter) { | 131 | getPrefefinedReasons (type: AbuseFilter) { |
103 | let reasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [ | 132 | let reasons: { id: AbusePredefinedReasonsString, label: string, description?: string, help?: string }[] = [ |
104 | { | 133 | { |