aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video-abuse
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/video-abuse')
-rw-r--r--client/src/app/shared/video-abuse/index.ts2
-rw-r--r--client/src/app/shared/video-abuse/video-abuse.model.ts8
-rw-r--r--client/src/app/shared/video-abuse/video-abuse.service.ts44
3 files changed, 54 insertions, 0 deletions
diff --git a/client/src/app/shared/video-abuse/index.ts b/client/src/app/shared/video-abuse/index.ts
new file mode 100644
index 000000000..563533ba5
--- /dev/null
+++ b/client/src/app/shared/video-abuse/index.ts
@@ -0,0 +1,2 @@
1export * from './video-abuse.service';
2export * from './video-abuse.model';
diff --git a/client/src/app/shared/video-abuse/video-abuse.model.ts b/client/src/app/shared/video-abuse/video-abuse.model.ts
new file mode 100644
index 000000000..bb0373027
--- /dev/null
+++ b/client/src/app/shared/video-abuse/video-abuse.model.ts
@@ -0,0 +1,8 @@
1export interface VideoAbuse {
2 id: string;
3 reason: string;
4 reporterPodHost: string;
5 reporterUsername: string;
6 videoId: string;
7 createdAt: Date;
8}
diff --git a/client/src/app/shared/video-abuse/video-abuse.service.ts b/client/src/app/shared/video-abuse/video-abuse.service.ts
new file mode 100644
index 000000000..2750a41c7
--- /dev/null
+++ b/client/src/app/shared/video-abuse/video-abuse.service.ts
@@ -0,0 +1,44 @@
1import { Injectable } from '@angular/core';
2import { Http } from '@angular/http';
3import { Observable } from 'rxjs/Observable';
4import 'rxjs/add/operator/catch';
5import 'rxjs/add/operator/map';
6
7import { AuthService } from '../core';
8import { AuthHttp } from '../auth';
9import { RestExtractor, ResultList } from '../rest';
10import { VideoAbuse } from './video-abuse.model';
11
12@Injectable()
13export class VideoAbuseService {
14 private static BASE_VIDEO_ABUSE_URL = '/api/v1/videos/';
15
16 constructor(
17 private authHttp: AuthHttp,
18 private restExtractor: RestExtractor
19 ) {}
20
21 getVideoAbuses() {
22 return this.authHttp.get(VideoAbuseService.BASE_VIDEO_ABUSE_URL + 'abuse')
23 .map(this.restExtractor.extractDataList)
24 .map(this.extractVideoAbuses)
25 }
26
27 reportVideo(id: string, reason: string) {
28 const body = {
29 reason
30 };
31 const url = VideoAbuseService.BASE_VIDEO_ABUSE_URL + id + '/abuse';
32
33 return this.authHttp.post(url, body)
34 .map(this.restExtractor.extractDataBool)
35 .catch((res) => this.restExtractor.handleError(res));
36 }
37
38 private extractVideoAbuses(result: ResultList) {
39 const videoAbuses: VideoAbuse[] = result.data;
40 const totalVideoAbuses = result.total;
41
42 return { videoAbuses, totalVideoAbuses };
43 }
44}