diff options
author | Josh Morel <morel.josh@hotmail.com> | 2019-04-02 05:26:47 -0400 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-04-02 11:26:47 +0200 |
commit | 7ccddd7b5250bd25a917a6e77e58b87b9484a2a4 (patch) | |
tree | e75dc991369c1768804fefa114eb2a832881087f /client/src/app/shared | |
parent | 12fed49ebab0c414713d57ea316b6488ae6bef99 (diff) | |
download | PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.gz PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.zst PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.zip |
add quarantine videos feature (#1637)
* add quarantine videos feature
* increase Notification settings test timeout
to 20000ms. was completing 7000 locally but timing out
after 10000 on travis
* fix quarantine video test issues
-propagate misspelling
-remove skip from server/tests/client.ts
* WIP use blacklist for moderator video approval
instead of video.quarantine boolean
* finish auto-blacklist feature
Diffstat (limited to 'client/src/app/shared')
3 files changed, 55 insertions, 10 deletions
diff --git a/client/src/app/shared/users/user-notification.model.ts b/client/src/app/shared/users/user-notification.model.ts index 097830752..7d0eb5ea2 100644 --- a/client/src/app/shared/users/user-notification.model.ts +++ b/client/src/app/shared/users/user-notification.model.ts | |||
@@ -54,6 +54,7 @@ export class UserNotification implements UserNotificationServer { | |||
54 | videoUrl?: string | 54 | videoUrl?: string |
55 | commentUrl?: any[] | 55 | commentUrl?: any[] |
56 | videoAbuseUrl?: string | 56 | videoAbuseUrl?: string |
57 | videoAutoBlacklistUrl?: string | ||
57 | accountUrl?: string | 58 | accountUrl?: string |
58 | videoImportIdentifier?: string | 59 | videoImportIdentifier?: string |
59 | videoImportUrl?: string | 60 | videoImportUrl?: string |
@@ -107,6 +108,11 @@ export class UserNotification implements UserNotificationServer { | |||
107 | this.videoUrl = this.buildVideoUrl(this.videoAbuse.video) | 108 | this.videoUrl = this.buildVideoUrl(this.videoAbuse.video) |
108 | break | 109 | break |
109 | 110 | ||
111 | case UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS: | ||
112 | this.videoAutoBlacklistUrl = '/admin/moderation/video-auto-blacklist/list' | ||
113 | this.videoUrl = this.buildVideoUrl(this.video) | ||
114 | break | ||
115 | |||
110 | case UserNotificationType.BLACKLIST_ON_MY_VIDEO: | 116 | case UserNotificationType.BLACKLIST_ON_MY_VIDEO: |
111 | this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video) | 117 | this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video) |
112 | break | 118 | break |
diff --git a/client/src/app/shared/users/user-notifications.component.html b/client/src/app/shared/users/user-notifications.component.html index 1c0af1bb0..6d2f2750e 100644 --- a/client/src/app/shared/users/user-notifications.component.html +++ b/client/src/app/shared/users/user-notifications.component.html | |||
@@ -36,6 +36,14 @@ | |||
36 | </div> | 36 | </div> |
37 | </ng-container> | 37 | </ng-container> |
38 | 38 | ||
39 | <ng-container i18n *ngSwitchCase="UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS"> | ||
40 | <my-global-icon iconName="no"></my-global-icon> | ||
41 | |||
42 | <div class="message"> | ||
43 | The recently added video <a (click)="markAsRead(notification)" [routerLink]="notification.videoUrl">{{ notification.video.name }}</a> has been <a (click)="markAsRead(notification)" [routerLink]="notification.videoAutoBlacklistUrl">auto-blacklisted</a> | ||
44 | </div> | ||
45 | </ng-container> | ||
46 | |||
39 | <ng-container i18n *ngSwitchCase="UserNotificationType.NEW_COMMENT_ON_MY_VIDEO"> | 47 | <ng-container i18n *ngSwitchCase="UserNotificationType.NEW_COMMENT_ON_MY_VIDEO"> |
40 | <img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.comment.account.avatarUrl" /> | 48 | <img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.comment.account.avatarUrl" /> |
41 | 49 | ||
diff --git a/client/src/app/shared/video-blacklist/video-blacklist.service.ts b/client/src/app/shared/video-blacklist/video-blacklist.service.ts index 94e46d7c2..a9eab9b6f 100644 --- a/client/src/app/shared/video-blacklist/video-blacklist.service.ts +++ b/client/src/app/shared/video-blacklist/video-blacklist.service.ts | |||
@@ -1,11 +1,13 @@ | |||
1 | import { catchError, map } from 'rxjs/operators' | 1 | import { catchError, map, concatMap, toArray } from 'rxjs/operators' |
2 | import { HttpClient, HttpParams } from '@angular/common/http' | 2 | import { HttpClient, HttpParams } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { SortMeta } from 'primeng/components/common/sortmeta' | 4 | import { SortMeta } from 'primeng/components/common/sortmeta' |
5 | import { Observable } from 'rxjs' | 5 | import { from as observableFrom, Observable } from 'rxjs' |
6 | import { VideoBlacklist, ResultList } from '../../../../../shared' | 6 | import { VideoBlacklist, VideoBlacklistType, ResultList } from '../../../../../shared' |
7 | import { Video } from '../video/video.model' | ||
7 | import { environment } from '../../../environments/environment' | 8 | import { environment } from '../../../environments/environment' |
8 | import { RestExtractor, RestPagination, RestService } from '../rest' | 9 | import { RestExtractor, RestPagination, RestService } from '../rest' |
10 | import { ComponentPagination } from '../rest/component-pagination.model' | ||
9 | 11 | ||
10 | @Injectable() | 12 | @Injectable() |
11 | export class VideoBlacklistService { | 13 | export class VideoBlacklistService { |
@@ -17,10 +19,14 @@ export class VideoBlacklistService { | |||
17 | private restExtractor: RestExtractor | 19 | private restExtractor: RestExtractor |
18 | ) {} | 20 | ) {} |
19 | 21 | ||
20 | listBlacklist (pagination: RestPagination, sort: SortMeta): Observable<ResultList<VideoBlacklist>> { | 22 | listBlacklist (pagination: RestPagination, sort: SortMeta, type?: VideoBlacklistType): Observable<ResultList<VideoBlacklist>> { |
21 | let params = new HttpParams() | 23 | let params = new HttpParams() |
22 | params = this.restService.addRestGetParams(params, pagination, sort) | 24 | params = this.restService.addRestGetParams(params, pagination, sort) |
23 | 25 | ||
26 | if (type) { | ||
27 | params = params.set('type', type.toString()) | ||
28 | } | ||
29 | |||
24 | return this.authHttp.get<ResultList<VideoBlacklist>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params }) | 30 | return this.authHttp.get<ResultList<VideoBlacklist>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params }) |
25 | .pipe( | 31 | .pipe( |
26 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | 32 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
@@ -28,12 +34,37 @@ export class VideoBlacklistService { | |||
28 | ) | 34 | ) |
29 | } | 35 | } |
30 | 36 | ||
31 | removeVideoFromBlacklist (videoId: number) { | 37 | getAutoBlacklistedAsVideoList (videoPagination: ComponentPagination): Observable<{ videos: Video[], totalVideos: number}> { |
32 | return this.authHttp.delete(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist') | 38 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) |
33 | .pipe( | 39 | |
34 | map(this.restExtractor.extractDataBool), | 40 | // prioritize first created since waiting longest |
35 | catchError(res => this.restExtractor.handleError(res)) | 41 | const AUTO_BLACKLIST_SORT = 'createdAt' |
36 | ) | 42 | |
43 | let params = new HttpParams() | ||
44 | params = this.restService.addRestGetParams(params, pagination, AUTO_BLACKLIST_SORT) | ||
45 | |||
46 | params = params.set('type', VideoBlacklistType.AUTO_BEFORE_PUBLISHED.toString()) | ||
47 | |||
48 | return this.authHttp.get<ResultList<VideoBlacklist>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params }) | ||
49 | .pipe( | ||
50 | map(res => { | ||
51 | const videos = res.data.map(videoBlacklist => new Video(videoBlacklist.video)) | ||
52 | const totalVideos = res.total | ||
53 | return { videos, totalVideos } | ||
54 | }), | ||
55 | catchError(res => this.restExtractor.handleError(res)) | ||
56 | ) | ||
57 | } | ||
58 | |||
59 | removeVideoFromBlacklist (videoIdArgs: number | number[]) { | ||
60 | const videoIds = Array.isArray(videoIdArgs) ? videoIdArgs : [ videoIdArgs ] | ||
61 | |||
62 | return observableFrom(videoIds) | ||
63 | .pipe( | ||
64 | concatMap(id => this.authHttp.delete(VideoBlacklistService.BASE_VIDEOS_URL + id + '/blacklist')), | ||
65 | toArray(), | ||
66 | catchError(err => this.restExtractor.handleError(err)) | ||
67 | ) | ||
37 | } | 68 | } |
38 | 69 | ||
39 | blacklistVideo (videoId: number, reason: string, unfederate: boolean) { | 70 | blacklistVideo (videoId: number, reason: string, unfederate: boolean) { |