aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-10 10:02:18 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-10 10:18:16 +0200
commit35bf0c83c80f59ca79f4b84fac8700f17adeb22d (patch)
treea9b2106096d6ba04d7219051b17fd32cfbe6a885
parent769d332177a5b02d5c2ffc134687d3b4ed65bae9 (diff)
downloadPeerTube-35bf0c83c80f59ca79f4b84fac8700f17adeb22d.tar.gz
PeerTube-35bf0c83c80f59ca79f4b84fac8700f17adeb22d.tar.zst
PeerTube-35bf0c83c80f59ca79f4b84fac8700f17adeb22d.zip
Video blacklist refractoring
-rw-r--r--client/src/app/+admin/admin-routing.module.ts4
-rw-r--r--client/src/app/+admin/admin.component.ts1
-rw-r--r--client/src/app/+admin/admin.module.ts9
-rw-r--r--client/src/app/+admin/blacklist/blacklist-list/index.ts1
-rw-r--r--client/src/app/+admin/blacklist/blacklist.routes.ts27
-rw-r--r--client/src/app/+admin/blacklist/index.ts4
-rw-r--r--client/src/app/+admin/blacklist/shared/index.ts1
-rw-r--r--client/src/app/+admin/video-blacklist/index.ts3
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts1
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html (renamed from client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html)4
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts (renamed from client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts)15
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist.component.ts (renamed from client/src/app/+admin/blacklist/blacklist.component.ts)3
-rw-r--r--client/src/app/+admin/video-blacklist/video-blacklist.routes.ts27
-rw-r--r--client/src/app/app.component.ts2
-rw-r--r--client/src/app/core/menu/menu-admin.component.html2
-rw-r--r--client/src/app/shared/index.ts1
-rw-r--r--client/src/app/shared/shared.module.ts2
-rw-r--r--client/src/app/shared/video-blacklist/index.ts1
-rw-r--r--client/src/app/shared/video-blacklist/video-blacklist.service.ts (renamed from client/src/app/+admin/blacklist/shared/blacklist.service.ts)24
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts19
-rw-r--r--client/src/app/videos/shared/video.service.ts6
-rw-r--r--server/controllers/api/blacklist.ts60
-rw-r--r--server/controllers/api/index.ts2
-rw-r--r--server/controllers/api/videos/blacklist.ts54
-rw-r--r--server/helpers/custom-validators/videos.ts34
-rw-r--r--server/lib/blacklist.ts20
-rw-r--r--server/lib/index.ts1
-rw-r--r--server/middlewares/validators/blacklist.ts35
-rw-r--r--server/middlewares/validators/index.ts2
-rw-r--r--server/middlewares/validators/video-blacklist.ts67
-rw-r--r--server/middlewares/validators/videos.ts58
-rw-r--r--server/tests/api/check-params/video-blacklist.ts12
-rw-r--r--server/tests/utils/video-blacklist.ts6
33 files changed, 239 insertions, 269 deletions
diff --git a/client/src/app/+admin/admin-routing.module.ts b/client/src/app/+admin/admin-routing.module.ts
index 0cd3e54c2..c3e4895ac 100644
--- a/client/src/app/+admin/admin-routing.module.ts
+++ b/client/src/app/+admin/admin-routing.module.ts
@@ -9,7 +9,7 @@ import { RequestSchedulersRoutes } from './request-schedulers'
9import { UsersRoutes } from './users' 9import { UsersRoutes } from './users'
10import { VideoAbusesRoutes } from './video-abuses' 10import { VideoAbusesRoutes } from './video-abuses'
11import { AdminGuard } from './admin-guard.service' 11import { AdminGuard } from './admin-guard.service'
12import { BlacklistRoutes } from './blacklist' 12import { VideoBlacklistRoutes } from './video-blacklist'
13 13
14const adminRoutes: Routes = [ 14const adminRoutes: Routes = [
15 { 15 {
@@ -27,7 +27,7 @@ const adminRoutes: Routes = [
27 ...RequestSchedulersRoutes, 27 ...RequestSchedulersRoutes,
28 ...UsersRoutes, 28 ...UsersRoutes,
29 ...VideoAbusesRoutes, 29 ...VideoAbusesRoutes,
30 ...BlacklistRoutes 30 ...VideoBlacklistRoutes
31 ] 31 ]
32 } 32 }
33] 33]
diff --git a/client/src/app/+admin/admin.component.ts b/client/src/app/+admin/admin.component.ts
index 93ec216bf..ecd62ee61 100644
--- a/client/src/app/+admin/admin.component.ts
+++ b/client/src/app/+admin/admin.component.ts
@@ -3,6 +3,5 @@ import { Component } from '@angular/core'
3@Component({ 3@Component({
4 template: '<router-outlet></router-outlet>' 4 template: '<router-outlet></router-outlet>'
5}) 5})
6
7export class AdminComponent { 6export class AdminComponent {
8} 7}
diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts
index c2dd60774..f29c501b0 100644
--- a/client/src/app/+admin/admin.module.ts
+++ b/client/src/app/+admin/admin.module.ts
@@ -6,7 +6,7 @@ import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendServic
6import { RequestSchedulersComponent, RequestSchedulersStatsComponent, RequestSchedulersService } from './request-schedulers' 6import { RequestSchedulersComponent, RequestSchedulersStatsComponent, RequestSchedulersService } from './request-schedulers'
7import { UsersComponent, UserAddComponent, UserUpdateComponent, UserListComponent, UserService } from './users' 7import { UsersComponent, UserAddComponent, UserUpdateComponent, UserListComponent, UserService } from './users'
8import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses' 8import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses'
9import { BlacklistComponent, BlacklistListComponent, BlacklistService } from './blacklist' 9import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-blacklist'
10import { SharedModule } from '../shared' 10import { SharedModule } from '../shared'
11import { AdminGuard } from './admin-guard.service' 11import { AdminGuard } from './admin-guard.service'
12 12
@@ -31,8 +31,8 @@ import { AdminGuard } from './admin-guard.service'
31 UserUpdateComponent, 31 UserUpdateComponent,
32 UserListComponent, 32 UserListComponent,
33 33
34 BlacklistComponent, 34 VideoBlacklistComponent,
35 BlacklistListComponent, 35 VideoBlacklistListComponent,
36 36
37 VideoAbusesComponent, 37 VideoAbusesComponent,
38 VideoAbuseListComponent 38 VideoAbuseListComponent
@@ -46,8 +46,7 @@ import { AdminGuard } from './admin-guard.service'
46 FriendService, 46 FriendService,
47 RequestSchedulersService, 47 RequestSchedulersService,
48 UserService, 48 UserService,
49 AdminGuard, 49 AdminGuard
50 BlacklistService
51 ] 50 ]
52}) 51})
53export class AdminModule { } 52export class AdminModule { }
diff --git a/client/src/app/+admin/blacklist/blacklist-list/index.ts b/client/src/app/+admin/blacklist/blacklist-list/index.ts
deleted file mode 100644
index 45f60a2b9..000000000
--- a/client/src/app/+admin/blacklist/blacklist-list/index.ts
+++ /dev/null
@@ -1 +0,0 @@
1export * from './blacklist-list.component'
diff --git a/client/src/app/+admin/blacklist/blacklist.routes.ts b/client/src/app/+admin/blacklist/blacklist.routes.ts
deleted file mode 100644
index 780347ca8..000000000
--- a/client/src/app/+admin/blacklist/blacklist.routes.ts
+++ /dev/null
@@ -1,27 +0,0 @@
1import { Routes } from '@angular/router'
2
3import { BlacklistComponent } from './blacklist.component'
4import { BlacklistListComponent } from './blacklist-list'
5
6export const BlacklistRoutes: Routes = [
7 {
8 path: 'blacklist',
9 component: BlacklistComponent,
10 children: [
11 {
12 path: '',
13 redirectTo: 'list',
14 pathMatch: 'full'
15 },
16 {
17 path: 'list',
18 component: BlacklistListComponent,
19 data: {
20 meta: {
21 title: 'Blacklisted videos'
22 }
23 }
24 }
25 ]
26 }
27]
diff --git a/client/src/app/+admin/blacklist/index.ts b/client/src/app/+admin/blacklist/index.ts
deleted file mode 100644
index 675dc1263..000000000
--- a/client/src/app/+admin/blacklist/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
1export * from './shared'
2export * from './blacklist-list'
3export * from './blacklist.component'
4export * from './blacklist.routes'
diff --git a/client/src/app/+admin/blacklist/shared/index.ts b/client/src/app/+admin/blacklist/shared/index.ts
deleted file mode 100644
index ad22e2d51..000000000
--- a/client/src/app/+admin/blacklist/shared/index.ts
+++ /dev/null
@@ -1 +0,0 @@
1export * from './blacklist.service'
diff --git a/client/src/app/+admin/video-blacklist/index.ts b/client/src/app/+admin/video-blacklist/index.ts
new file mode 100644
index 000000000..a5451e2e1
--- /dev/null
+++ b/client/src/app/+admin/video-blacklist/index.ts
@@ -0,0 +1,3 @@
1export * from './video-blacklist-list'
2export * from './video-blacklist.component'
3export * from './video-blacklist.routes'
diff --git a/client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts b/client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts
new file mode 100644
index 000000000..4daf64187
--- /dev/null
+++ b/client/src/app/+admin/video-blacklist/video-blacklist-list/index.ts
@@ -0,0 +1 @@
export * from './video-blacklist-list.component'
diff --git a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html
index 5d4636ee9..05d116798 100644
--- a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.html
+++ b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.html
@@ -18,8 +18,8 @@
18 <p-column field="createdAt" header="Created date" [sortable]="true"></p-column> 18 <p-column field="createdAt" header="Created date" [sortable]="true"></p-column>
19 <p-column header="Delete" styleClass="action-cell"> 19 <p-column header="Delete" styleClass="action-cell">
20 <ng-template pTemplate="body" let-entry="rowData"> 20 <ng-template pTemplate="body" let-entry="rowData">
21 <span (click)="removeVideoFromBlacklist(entry)" class="glyphicon glyphicon-remove glyphicon-black" title="Remove this video"></span> 21 <span (click)="removeVideoFromBlacklist(entry)" class="glyphicon glyphicon-remove glyphicon-black" title="Remove this video from blacklist"></span>
22 </ng-template> 22 </ng-template>
23 </p-column> 23 </p-column>
24 </p-dataTable> 24 </p-dataTable>
25 </div> 25 </div>
diff --git a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts
index b308054ed..56024b247 100644
--- a/client/src/app/+admin/blacklist/blacklist-list/blacklist-list.component.ts
+++ b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts
@@ -4,16 +4,15 @@ import { SortMeta } from 'primeng/components/common/sortmeta'
4import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
5 5
6import { ConfirmService } from '../../../core' 6import { ConfirmService } from '../../../core'
7import { RestTable, RestPagination } from '../../../shared' 7import { VideoBlacklistService, RestTable, RestPagination } from '../../../shared'
8import { BlacklistService } from '../shared'
9import { BlacklistedVideo } from '../../../../../../shared' 8import { BlacklistedVideo } from '../../../../../../shared'
10 9
11@Component({ 10@Component({
12 selector: 'my-blacklist-list', 11 selector: 'my-video-blacklist-list',
13 templateUrl: './blacklist-list.component.html', 12 templateUrl: './video-blacklist-list.component.html',
14 styleUrls: [] 13 styleUrls: []
15}) 14})
16export class BlacklistListComponent extends RestTable implements OnInit { 15export class VideoBlacklistListComponent extends RestTable implements OnInit {
17 blacklist: BlacklistedVideo[] = [] 16 blacklist: BlacklistedVideo[] = []
18 totalRecords = 0 17 totalRecords = 0
19 rowsPerPage = 10 18 rowsPerPage = 10
@@ -23,7 +22,7 @@ export class BlacklistListComponent extends RestTable implements OnInit {
23 constructor ( 22 constructor (
24 private notificationsService: NotificationsService, 23 private notificationsService: NotificationsService,
25 private confirmService: ConfirmService, 24 private confirmService: ConfirmService,
26 private blacklistService: BlacklistService 25 private videoBlacklistService: VideoBlacklistService
27 ) { 26 ) {
28 super() 27 super()
29 } 28 }
@@ -39,7 +38,7 @@ export class BlacklistListComponent extends RestTable implements OnInit {
39 res => { 38 res => {
40 if (res === false) return 39 if (res === false) return
41 40
42 this.blacklistService.removeVideoFromBlacklist(entry).subscribe( 41 this.videoBlacklistService.removeVideoFromBlacklist(entry.videoId).subscribe(
43 status => { 42 status => {
44 this.notificationsService.success('Success', `Video ${entry.name} removed from the blacklist.`) 43 this.notificationsService.success('Success', `Video ${entry.name} removed from the blacklist.`)
45 this.loadData() 44 this.loadData()
@@ -52,7 +51,7 @@ export class BlacklistListComponent extends RestTable implements OnInit {
52 } 51 }
53 52
54 protected loadData () { 53 protected loadData () {
55 this.blacklistService.getBlacklist(this.pagination, this.sort) 54 this.videoBlacklistService.listBlacklist(this.pagination, this.sort)
56 .subscribe( 55 .subscribe(
57 resultList => { 56 resultList => {
58 this.blacklist = resultList.data 57 this.blacklist = resultList.data
diff --git a/client/src/app/+admin/blacklist/blacklist.component.ts b/client/src/app/+admin/video-blacklist/video-blacklist.component.ts
index ce8fe4298..24b8c98f8 100644
--- a/client/src/app/+admin/blacklist/blacklist.component.ts
+++ b/client/src/app/+admin/video-blacklist/video-blacklist.component.ts
@@ -3,6 +3,5 @@ import { Component } from '@angular/core'
3@Component({ 3@Component({
4 template: '<router-outlet></router-outlet>' 4 template: '<router-outlet></router-outlet>'
5}) 5})
6 6export class VideoBlacklistComponent {
7export class BlacklistComponent {
8} 7}
diff --git a/client/src/app/+admin/video-blacklist/video-blacklist.routes.ts b/client/src/app/+admin/video-blacklist/video-blacklist.routes.ts
new file mode 100644
index 000000000..682b6f8bd
--- /dev/null
+++ b/client/src/app/+admin/video-blacklist/video-blacklist.routes.ts
@@ -0,0 +1,27 @@
1import { Routes } from '@angular/router'
2
3import { VideoBlacklistComponent } from './video-blacklist.component'
4import { VideoBlacklistListComponent } from './video-blacklist-list'
5
6export const VideoBlacklistRoutes: Routes = [
7 {
8 path: 'video-blacklist',
9 component: VideoBlacklistComponent,
10 children: [
11 {
12 path: '',
13 redirectTo: 'list',
14 pathMatch: 'full'
15 },
16 {
17 path: 'list',
18 component: VideoBlacklistListComponent,
19 data: {
20 meta: {
21 title: 'Blacklisted videos'
22 }
23 }
24 }
25 ]
26 }
27]
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index 68719f73d..7d890e72a 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -11,7 +11,7 @@ import { UserService } from './shared'
11}) 11})
12export class AppComponent implements OnInit { 12export class AppComponent implements OnInit {
13 notificationOptions = { 13 notificationOptions = {
14 timeOut: 3000, 14 timeOut: 5000,
15 lastOnBottom: true, 15 lastOnBottom: true,
16 clickToClose: true, 16 clickToClose: true,
17 maxLength: 0, 17 maxLength: 0,
diff --git a/client/src/app/core/menu/menu-admin.component.html b/client/src/app/core/menu/menu-admin.component.html
index f512a4e67..edacdee6d 100644
--- a/client/src/app/core/menu/menu-admin.component.html
+++ b/client/src/app/core/menu/menu-admin.component.html
@@ -20,7 +20,7 @@
20 Video abuses 20 Video abuses
21 </a> 21 </a>
22 22
23 <a routerLink="/admin/blacklist/list" routerLinkActive="active"> 23 <a routerLink="/admin/video-blacklist/list" routerLinkActive="active">
24 <span class="hidden-xs glyphicon glyphicon-eye-close"></span> 24 <span class="hidden-xs glyphicon glyphicon-eye-close"></span>
25 Video blacklist 25 Video blacklist
26 </a> 26 </a>
diff --git a/client/src/app/shared/index.ts b/client/src/app/shared/index.ts
index 212645c51..79bf5ef43 100644
--- a/client/src/app/shared/index.ts
+++ b/client/src/app/shared/index.ts
@@ -4,5 +4,6 @@ export * from './rest'
4export * from './search' 4export * from './search'
5export * from './users' 5export * from './users'
6export * from './video-abuse' 6export * from './video-abuse'
7export * from './video-blacklist'
7export * from './shared.module' 8export * from './shared.module'
8export * from './utils' 9export * from './utils'
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts
index 56da62fc4..47f651590 100644
--- a/client/src/app/shared/shared.module.ts
+++ b/client/src/app/shared/shared.module.ts
@@ -18,6 +18,7 @@ import { RestExtractor, RestService } from './rest'
18import { SearchComponent, SearchService } from './search' 18import { SearchComponent, SearchService } from './search'
19import { UserService } from './users' 19import { UserService } from './users'
20import { VideoAbuseService } from './video-abuse' 20import { VideoAbuseService } from './video-abuse'
21import { VideoBlacklistService } from './video-blacklist'
21 22
22@NgModule({ 23@NgModule({
23 imports: [ 24 imports: [
@@ -67,6 +68,7 @@ import { VideoAbuseService } from './video-abuse'
67 RestService, 68 RestService,
68 SearchService, 69 SearchService,
69 VideoAbuseService, 70 VideoAbuseService,
71 VideoBlacklistService,
70 UserService 72 UserService
71 ] 73 ]
72}) 74})
diff --git a/client/src/app/shared/video-blacklist/index.ts b/client/src/app/shared/video-blacklist/index.ts
new file mode 100644
index 000000000..bfb026441
--- /dev/null
+++ b/client/src/app/shared/video-blacklist/index.ts
@@ -0,0 +1 @@
export * from './video-blacklist.service'
diff --git a/client/src/app/+admin/blacklist/shared/blacklist.service.ts b/client/src/app/shared/video-blacklist/video-blacklist.service.ts
index ee2bf82e9..17373d52e 100644
--- a/client/src/app/+admin/blacklist/shared/blacklist.service.ts
+++ b/client/src/app/shared/video-blacklist/video-blacklist.service.ts
@@ -6,13 +6,13 @@ import 'rxjs/add/operator/map'
6 6
7import { SortMeta } from 'primeng/components/common/sortmeta' 7import { SortMeta } from 'primeng/components/common/sortmeta'
8 8
9import { RestExtractor, RestPagination, RestService } from '../../../shared' 9import { RestExtractor, RestPagination, RestService } from '../rest'
10import { Utils } from '../../../shared' 10import { Utils } from '../utils'
11import { BlacklistedVideo, ResultList } from '../../../../../../shared' 11import { BlacklistedVideo, ResultList } from '../../../../../shared'
12 12
13@Injectable() 13@Injectable()
14export class BlacklistService { 14export class VideoBlacklistService {
15 private static BASE_BLACKLISTS_URL = API_URL + '/api/v1/blacklist/' 15 private static BASE_VIDEOS_URL = API_URL + '/api/v1/videos/'
16 16
17 constructor ( 17 constructor (
18 private authHttp: HttpClient, 18 private authHttp: HttpClient,
@@ -20,22 +20,28 @@ export class BlacklistService {
20 private restExtractor: RestExtractor 20 private restExtractor: RestExtractor
21 ) {} 21 ) {}
22 22
23 getBlacklist (pagination: RestPagination, sort: SortMeta): Observable<ResultList<BlacklistedVideo>> { 23 listBlacklist (pagination: RestPagination, sort: SortMeta): Observable<ResultList<BlacklistedVideo>> {
24 let params = new HttpParams() 24 let params = new HttpParams()
25 params = this.restService.addRestGetParams(params, pagination, sort) 25 params = this.restService.addRestGetParams(params, pagination, sort)
26 26
27 return this.authHttp.get<ResultList<BlacklistedVideo>>(BlacklistService.BASE_BLACKLISTS_URL, { params }) 27 return this.authHttp.get<ResultList<BlacklistedVideo>>(VideoBlacklistService.BASE_VIDEOS_URL + 'blacklist', { params })
28 .map(res => this.restExtractor.convertResultListDateToHuman(res)) 28 .map(res => this.restExtractor.convertResultListDateToHuman(res))
29 .map(res => this.restExtractor.applyToResultListData(res, this.formatBlacklistedVideo.bind(this))) 29 .map(res => this.restExtractor.applyToResultListData(res, this.formatBlacklistedVideo.bind(this)))
30 .catch(res => this.restExtractor.handleError(res)) 30 .catch(res => this.restExtractor.handleError(res))
31 } 31 }
32 32
33 removeVideoFromBlacklist (entry: BlacklistedVideo) { 33 removeVideoFromBlacklist (videoId: number) {
34 return this.authHttp.delete(BlacklistService.BASE_BLACKLISTS_URL + entry.id) 34 return this.authHttp.delete(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist')
35 .map(this.restExtractor.extractDataBool) 35 .map(this.restExtractor.extractDataBool)
36 .catch(res => this.restExtractor.handleError(res)) 36 .catch(res => this.restExtractor.handleError(res))
37 } 37 }
38 38
39 blacklistVideo (videoId: number) {
40 return this.authHttp.post(VideoBlacklistService.BASE_VIDEOS_URL + videoId + '/blacklist', {})
41 .map(this.restExtractor.extractDataBool)
42 .catch(res => this.restExtractor.handleError(res))
43 }
44
39 private formatBlacklistedVideo (blacklistedVideo: BlacklistedVideo) { 45 private formatBlacklistedVideo (blacklistedVideo: BlacklistedVideo) {
40 return Object.assign(blacklistedVideo, { 46 return Object.assign(blacklistedVideo, {
41 createdAt: Utils.dateToHuman(blacklistedVideo.createdAt) 47 createdAt: Utils.dateToHuman(blacklistedVideo.createdAt)
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index 874dd5997..bd98e877c 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -14,7 +14,7 @@ import { VideoMagnetComponent } from './video-magnet.component'
14import { VideoShareComponent } from './video-share.component' 14import { VideoShareComponent } from './video-share.component'
15import { VideoReportComponent } from './video-report.component' 15import { VideoReportComponent } from './video-report.component'
16import { Video, VideoService } from '../shared' 16import { Video, VideoService } from '../shared'
17import { WebTorrentService } from './webtorrent.service' 17import { VideoBlacklistService } from '../../shared'
18import { UserVideoRateType, VideoRateType } from '../../../../../shared' 18import { UserVideoRateType, VideoRateType } from '../../../../../shared'
19 19
20@Component({ 20@Component({
@@ -45,6 +45,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
45 private route: ActivatedRoute, 45 private route: ActivatedRoute,
46 private router: Router, 46 private router: Router,
47 private videoService: VideoService, 47 private videoService: VideoService,
48 private videoBlacklistService: VideoBlacklistService,
48 private confirmService: ConfirmService, 49 private confirmService: ConfirmService,
49 private metaService: MetaService, 50 private metaService: MetaService,
50 private authService: AuthService, 51 private authService: AuthService,
@@ -137,15 +138,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
137 res => { 138 res => {
138 if (res === false) return 139 if (res === false) return
139 140
140 this.videoService.blacklistVideo(this.video.id) 141 this.videoBlacklistService.blacklistVideo(this.video.id)
141 .subscribe( 142 .subscribe(
142 status => { 143 status => {
143 this.notificationsService.success('Success', `Video ${this.video.name} had been blacklisted.`) 144 this.notificationsService.success('Success', `Video ${this.video.name} had been blacklisted.`)
144 this.router.navigate(['/videos/list']) 145 this.router.navigate(['/videos/list'])
145 }, 146 },
146 147
147 error => this.notificationsService.error('Error', error.text) 148 error => this.notificationsService.error('Error', error.text)
148 ) 149 )
149 } 150 }
150 ) 151 )
151 } 152 }
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index 037c20416..fe7f9108d 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -122,12 +122,6 @@ export class VideoService {
122 .catch(res => this.restExtractor.handleError(res)) 122 .catch(res => this.restExtractor.handleError(res))
123 } 123 }
124 124
125 blacklistVideo (id: number) {
126 return this.authHttp.post(VideoService.BASE_VIDEO_URL + id + '/blacklist', {})
127 .map(this.restExtractor.extractDataBool)
128 .catch(res => this.restExtractor.handleError(res))
129 }
130
131 private videoPaginationToRestPagination (videoPagination: VideoPagination) { 125 private videoPaginationToRestPagination (videoPagination: VideoPagination) {
132 const start: number = (videoPagination.currentPage - 1) * videoPagination.itemsPerPage 126 const start: number = (videoPagination.currentPage - 1) * videoPagination.itemsPerPage
133 const count: number = videoPagination.itemsPerPage 127 const count: number = videoPagination.itemsPerPage
diff --git a/server/controllers/api/blacklist.ts b/server/controllers/api/blacklist.ts
deleted file mode 100644
index 9b2d8017e..000000000
--- a/server/controllers/api/blacklist.ts
+++ /dev/null
@@ -1,60 +0,0 @@
1import * as express from 'express'
2
3import { database } from '../../initializers'
4import { getFormattedObjects } from '../../helpers'
5import { BlacklistedVideo } from '../../../shared'
6import { BlacklistedVideoInstance } from '../../models'
7
8import {
9 removeVideoFromBlacklist
10} from '../../lib'
11import {
12 authenticate,
13 ensureIsAdmin,
14 paginationValidator,
15 blacklistSortValidator,
16 setBlacklistSort,
17 setPagination,
18 blacklistRemoveValidator
19} from '../../middlewares'
20
21const blacklistRouter = express.Router()
22
23blacklistRouter.get('/',
24 authenticate,
25 ensureIsAdmin,
26 paginationValidator,
27 blacklistSortValidator,
28 setBlacklistSort,
29 setPagination,
30 listBlacklist
31)
32
33blacklistRouter.delete('/:id',
34 authenticate,
35 ensureIsAdmin,
36 blacklistRemoveValidator,
37 removeVideoFromBlacklistController
38)
39
40// ---------------------------------------------------------------------------
41
42export {
43 blacklistRouter
44}
45
46// ---------------------------------------------------------------------------
47
48function listBlacklist (req: express.Request, res: express.Response, next: express.NextFunction) {
49 database.BlacklistedVideo.listForApi(req.query.start, req.query.count, req.query.sort)
50 .then(resultList => res.json(getFormattedObjects<BlacklistedVideo, BlacklistedVideoInstance>(resultList.data, resultList.total)))
51 .catch(err => next(err))
52}
53
54function removeVideoFromBlacklistController (req: express.Request, res: express.Response, next: express.NextFunction) {
55 const entry = res.locals.blacklistEntryToRemove as BlacklistedVideoInstance
56
57 removeVideoFromBlacklist(entry)
58 .then(() => res.sendStatus(204))
59 .catch(err => next(err))
60}
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index fdc887915..a9205b33c 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -9,7 +9,6 @@ import { remoteRouter } from './remote'
9import { requestSchedulerRouter } from './request-schedulers' 9import { requestSchedulerRouter } from './request-schedulers'
10import { usersRouter } from './users' 10import { usersRouter } from './users'
11import { videosRouter } from './videos' 11import { videosRouter } from './videos'
12import { blacklistRouter } from './blacklist'
13 12
14const apiRouter = express.Router() 13const apiRouter = express.Router()
15 14
@@ -20,7 +19,6 @@ apiRouter.use('/remote', remoteRouter)
20apiRouter.use('/request-schedulers', requestSchedulerRouter) 19apiRouter.use('/request-schedulers', requestSchedulerRouter)
21apiRouter.use('/users', usersRouter) 20apiRouter.use('/users', usersRouter)
22apiRouter.use('/videos', videosRouter) 21apiRouter.use('/videos', videosRouter)
23apiRouter.use('/blacklist', blacklistRouter)
24apiRouter.use('/ping', pong) 22apiRouter.use('/ping', pong)
25apiRouter.use('/*', badRequest) 23apiRouter.use('/*', badRequest)
26 24
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts
index d8f2068ec..66311598e 100644
--- a/server/controllers/api/videos/blacklist.ts
+++ b/server/controllers/api/videos/blacklist.ts
@@ -1,22 +1,46 @@
1import * as express from 'express' 1import * as express from 'express'
2 2
3import { database as db } from '../../../initializers/database' 3import { database as db } from '../../../initializers'
4import { logger } from '../../../helpers' 4import { logger, getFormattedObjects } from '../../../helpers'
5import { 5import {
6 authenticate, 6 authenticate,
7 ensureIsAdmin, 7 ensureIsAdmin,
8 videosBlacklistValidator 8 videosBlacklistAddValidator,
9 videosBlacklistRemoveValidator,
10 paginationValidator,
11 blacklistSortValidator,
12 setBlacklistSort,
13 setPagination
9} from '../../../middlewares' 14} from '../../../middlewares'
15import { BlacklistedVideoInstance } from '../../../models'
16import { BlacklistedVideo } from '../../../../shared'
10 17
11const blacklistRouter = express.Router() 18const blacklistRouter = express.Router()
12 19
13blacklistRouter.post('/:id/blacklist', 20blacklistRouter.post('/:videoId/blacklist',
14 authenticate, 21 authenticate,
15 ensureIsAdmin, 22 ensureIsAdmin,
16 videosBlacklistValidator, 23 videosBlacklistAddValidator,
17 addVideoToBlacklist 24 addVideoToBlacklist
18) 25)
19 26
27blacklistRouter.get('/blacklist',
28 authenticate,
29 ensureIsAdmin,
30 paginationValidator,
31 blacklistSortValidator,
32 setBlacklistSort,
33 setPagination,
34 listBlacklist
35)
36
37blacklistRouter.delete('/:videoId/blacklist',
38 authenticate,
39 ensureIsAdmin,
40 videosBlacklistRemoveValidator,
41 removeVideoFromBlacklistController
42)
43
20// --------------------------------------------------------------------------- 44// ---------------------------------------------------------------------------
21 45
22export { 46export {
@@ -39,3 +63,23 @@ function addVideoToBlacklist (req: express.Request, res: express.Response, next:
39 return next(err) 63 return next(err)
40 }) 64 })
41} 65}
66
67function listBlacklist (req: express.Request, res: express.Response, next: express.NextFunction) {
68 db.BlacklistedVideo.listForApi(req.query.start, req.query.count, req.query.sort)
69 .then(resultList => res.json(getFormattedObjects<BlacklistedVideo, BlacklistedVideoInstance>(resultList.data, resultList.total)))
70 .catch(err => next(err))
71}
72
73function removeVideoFromBlacklistController (req: express.Request, res: express.Response, next: express.NextFunction) {
74 const blacklistedVideo = res.locals.blacklistedVideo as BlacklistedVideoInstance
75
76 blacklistedVideo.destroy()
77 .then(() => {
78 logger.info('Video %s removed from blacklist.', res.locals.video.uuid)
79 res.sendStatus(204)
80 })
81 .catch(err => {
82 logger.error('Some error while removing video %s from blacklist.', res.locals.video.uuid, err)
83 next(err)
84 })
85}
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index a31aca019..05d1dc607 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -1,5 +1,7 @@
1import { values } from 'lodash' 1import { values } from 'lodash'
2import * as validator from 'validator' 2import * as validator from 'validator'
3import * as Promise from 'bluebird'
4import * as express from 'express'
3import 'express-validator' 5import 'express-validator'
4import 'multer' 6import 'multer'
5 7
@@ -8,10 +10,13 @@ import {
8 VIDEO_CATEGORIES, 10 VIDEO_CATEGORIES,
9 VIDEO_LICENCES, 11 VIDEO_LICENCES,
10 VIDEO_LANGUAGES, 12 VIDEO_LANGUAGES,
11 VIDEO_RATE_TYPES 13 VIDEO_RATE_TYPES,
14 database as db
12} from '../../initializers' 15} from '../../initializers'
13import { isUserUsernameValid } from './users' 16import { isUserUsernameValid } from './users'
14import { isArray, exists } from './misc' 17import { isArray, exists } from './misc'
18import { VideoInstance } from '../../models'
19import { logger } from '../../helpers'
15import { VideoRateType } from '../../../shared' 20import { VideoRateType } from '../../../shared'
16 21
17const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS 22const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
@@ -138,6 +143,30 @@ function isVideoFileInfoHashValid (value: string) {
138 return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) 143 return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)
139} 144}
140 145
146function checkVideoExists (id: string, res: express.Response, callback: () => void) {
147 let promise: Promise<VideoInstance>
148 if (validator.isInt(id)) {
149 promise = db.Video.loadAndPopulateAuthorAndPodAndTags(+id)
150 } else { // UUID
151 promise = db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(id)
152 }
153
154 promise.then(video => {
155 if (!video) {
156 return res.status(404)
157 .json({ error: 'Video not found' })
158 .end()
159 }
160
161 res.locals.video = video
162 callback()
163 })
164 .catch(err => {
165 logger.error('Error in video request validator.', err)
166 return res.sendStatus(500)
167 })
168}
169
141// --------------------------------------------------------------------------- 170// ---------------------------------------------------------------------------
142 171
143export { 172export {
@@ -166,5 +195,6 @@ export {
166 isVideoDislikesValid, 195 isVideoDislikesValid,
167 isVideoEventCountValid, 196 isVideoEventCountValid,
168 isVideoFileSizeValid, 197 isVideoFileSizeValid,
169 isVideoFileResolutionValid 198 isVideoFileResolutionValid,
199 checkVideoExists
170} 200}
diff --git a/server/lib/blacklist.ts b/server/lib/blacklist.ts
deleted file mode 100644
index dcf8aa03c..000000000
--- a/server/lib/blacklist.ts
+++ /dev/null
@@ -1,20 +0,0 @@
1import { logger } from '../helpers'
2import { BlacklistedVideoInstance } from '../models'
3
4function removeVideoFromBlacklist (entry: BlacklistedVideoInstance) {
5 return entry.destroy()
6 .then(() => {
7 logger.info('Video removed from the blacklist')
8 })
9 .catch(err => {
10 logger.error('Some error while removing video from the blacklist.', err)
11 })
12}
13
14// ---------------------------------------------------------------------------
15
16export {
17 removeVideoFromBlacklist
18}
19
20// ---------------------------------------------------------------------------
diff --git a/server/lib/index.ts b/server/lib/index.ts
index df781f29f..8628da4dd 100644
--- a/server/lib/index.ts
+++ b/server/lib/index.ts
@@ -3,4 +3,3 @@ export * from './jobs'
3export * from './request' 3export * from './request'
4export * from './friends' 4export * from './friends'
5export * from './oauth-model' 5export * from './oauth-model'
6export * from './blacklist'
diff --git a/server/middlewares/validators/blacklist.ts b/server/middlewares/validators/blacklist.ts
deleted file mode 100644
index fe8fa40a4..000000000
--- a/server/middlewares/validators/blacklist.ts
+++ /dev/null
@@ -1,35 +0,0 @@
1import { param } from 'express-validator/check'
2import * as express from 'express'
3
4import { database as db } from '../../initializers/database'
5import { checkErrors } from './utils'
6import { logger } from '../../helpers'
7
8const blacklistRemoveValidator = [
9 param('id').isNumeric().not().isEmpty().withMessage('Should have a valid id'),
10
11 (req: express.Request, res: express.Response, next: express.NextFunction) => {
12 logger.debug('Checking blacklistRemove parameters.', { parameters: req.params })
13
14 checkErrors(req, res, () => {
15 db.BlacklistedVideo.loadById(req.params.id)
16 .then(entry => {
17 if (!entry) return res.status(404).send('Blacklisted video not found')
18
19 res.locals.blacklistEntryToRemove = entry
20
21 next()
22 })
23 .catch(err => {
24 logger.error('Error in blacklistRemove request validator', { error: err })
25 return res.sendStatus(500)
26 })
27 })
28 }
29]
30
31// ---------------------------------------------------------------------------
32
33export {
34 blacklistRemoveValidator
35}
diff --git a/server/middlewares/validators/index.ts b/server/middlewares/validators/index.ts
index a6198e22c..418fa5f1d 100644
--- a/server/middlewares/validators/index.ts
+++ b/server/middlewares/validators/index.ts
@@ -4,4 +4,4 @@ export * from './pods'
4export * from './sort' 4export * from './sort'
5export * from './users' 5export * from './users'
6export * from './videos' 6export * from './videos'
7export * from './blacklist' 7export * from './video-blacklist'
diff --git a/server/middlewares/validators/video-blacklist.ts b/server/middlewares/validators/video-blacklist.ts
new file mode 100644
index 000000000..30c6d4bd9
--- /dev/null
+++ b/server/middlewares/validators/video-blacklist.ts
@@ -0,0 +1,67 @@
1import { param } from 'express-validator/check'
2import * as express from 'express'
3
4import { database as db } from '../../initializers/database'
5import { checkErrors } from './utils'
6import { logger, isVideoIdOrUUIDValid, checkVideoExists } from '../../helpers'
7
8const videosBlacklistRemoveValidator = [
9 param('videoId').custom(isVideoIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
10
11 (req: express.Request, res: express.Response, next: express.NextFunction) => {
12 logger.debug('Checking blacklistRemove parameters.', { parameters: req.params })
13
14 checkErrors(req, res, () => {
15 checkVideoExists(req.params.videoId, res, () => {
16 checkVideoIsBlacklisted(req, res, next)
17 })
18 })
19 }
20]
21
22const videosBlacklistAddValidator = [
23 param('videoId').custom(isVideoIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
24
25 (req: express.Request, res: express.Response, next: express.NextFunction) => {
26 logger.debug('Checking videosBlacklist parameters', { parameters: req.params })
27
28 checkErrors(req, res, () => {
29 checkVideoExists(req.params.videoId, res, () => {
30 checkVideoIsBlacklistable(req, res, next)
31 })
32 })
33 }
34]
35
36// ---------------------------------------------------------------------------
37
38export {
39 videosBlacklistAddValidator,
40 videosBlacklistRemoveValidator
41}
42// ---------------------------------------------------------------------------
43
44function checkVideoIsBlacklistable (req: express.Request, res: express.Response, callback: () => void) {
45 if (res.locals.video.isOwned() === true) {
46 return res.status(403)
47 .json({ error: 'Cannot blacklist a local video' })
48 .end()
49 }
50
51 callback()
52}
53
54function checkVideoIsBlacklisted (req: express.Request, res: express.Response, callback: () => void) {
55 db.BlacklistedVideo.loadByVideoId(res.locals.video.id)
56 .then(blacklistedVideo => {
57 if (!blacklistedVideo) return res.status(404).send('Blacklisted video not found')
58
59 res.locals.blacklistedVideo = blacklistedVideo
60
61 callback()
62 })
63 .catch(err => {
64 logger.error('Error in blacklistRemove request validator', { error: err })
65 return res.sendStatus(500)
66 })
67}
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index 5f213f974..deed07524 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -1,7 +1,5 @@
1import { body, param, query } from 'express-validator/check' 1import { body, param, query } from 'express-validator/check'
2import * as express from 'express' 2import * as express from 'express'
3import * as Promise from 'bluebird'
4import * as validator from 'validator'
5 3
6import { database as db } from '../../initializers/database' 4import { database as db } from '../../initializers/database'
7import { checkErrors } from './utils' 5import { checkErrors } from './utils'
@@ -20,9 +18,9 @@ import {
20 isVideoIdOrUUIDValid, 18 isVideoIdOrUUIDValid,
21 isVideoAbuseReasonValid, 19 isVideoAbuseReasonValid,
22 isVideoRatingTypeValid, 20 isVideoRatingTypeValid,
23 getDurationFromVideoFile 21 getDurationFromVideoFile,
22 checkVideoExists
24} from '../../helpers' 23} from '../../helpers'
25import { VideoInstance } from '../../models'
26 24
27const videosAddValidator = [ 25const videosAddValidator = [
28 body('videofile').custom((value, { req }) => isVideoFile(req.files)).withMessage('Should have a valid file'), 26 body('videofile').custom((value, { req }) => isVideoFile(req.files)).withMessage('Should have a valid file'),
@@ -186,20 +184,6 @@ const videoRateValidator = [
186 } 184 }
187] 185]
188 186
189const videosBlacklistValidator = [
190 param('id').custom(isVideoIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
191
192 (req: express.Request, res: express.Response, next: express.NextFunction) => {
193 logger.debug('Checking videosBlacklist parameters', { parameters: req.params })
194
195 checkErrors(req, res, () => {
196 checkVideoExists(req.params.id, res, () => {
197 checkVideoIsBlacklistable(req, res, next)
198 })
199 })
200 }
201]
202
203// --------------------------------------------------------------------------- 187// ---------------------------------------------------------------------------
204 188
205export { 189export {
@@ -211,37 +195,11 @@ export {
211 195
212 videoAbuseReportValidator, 196 videoAbuseReportValidator,
213 197
214 videoRateValidator, 198 videoRateValidator
215
216 videosBlacklistValidator
217} 199}
218 200
219// --------------------------------------------------------------------------- 201// ---------------------------------------------------------------------------
220 202
221function checkVideoExists (id: string, res: express.Response, callback: () => void) {
222 let promise: Promise<VideoInstance>
223 if (validator.isInt(id)) {
224 promise = db.Video.loadAndPopulateAuthorAndPodAndTags(+id)
225 } else { // UUID
226 promise = db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(id)
227 }
228
229 promise.then(video => {
230 if (!video) {
231 return res.status(404)
232 .json({ error: 'Video not found' })
233 .end()
234 }
235
236 res.locals.video = video
237 callback()
238 })
239 .catch(err => {
240 logger.error('Error in video request validator.', err)
241 return res.sendStatus(500)
242 })
243}
244
245function checkUserCanDeleteVideo (userId: number, res: express.Response, callback: () => void) { 203function checkUserCanDeleteVideo (userId: number, res: express.Response, callback: () => void) {
246 // Retrieve the user who did the request 204 // Retrieve the user who did the request
247 db.User.loadById(userId) 205 db.User.loadById(userId)
@@ -269,13 +227,3 @@ function checkUserCanDeleteVideo (userId: number, res: express.Response, callbac
269 return res.sendStatus(500) 227 return res.sendStatus(500)
270 }) 228 })
271} 229}
272
273function checkVideoIsBlacklistable (req: express.Request, res: express.Response, callback: () => void) {
274 if (res.locals.video.isOwned() === true) {
275 return res.status(403)
276 .json({ error: 'Cannot blacklist a local video' })
277 .end()
278 }
279
280 callback()
281}
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index 80e6f8011..eb16b3af0 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -81,10 +81,10 @@ describe('Test video blacklist API validators', function () {
81 }) 81 })
82 82
83 describe('When removing a video in blacklist', function () { 83 describe('When removing a video in blacklist', function () {
84 const basePath = '/api/v1/blacklist/' 84 const basePath = '/api/v1/videos/'
85 85
86 it('Should fail with a non authenticated user', async function () { 86 it('Should fail with a non authenticated user', async function () {
87 const path = basePath + server.video.id 87 const path = basePath + server.video.id + '/blacklist'
88 88
89 await request(server.url) 89 await request(server.url)
90 .delete(path) 90 .delete(path)
@@ -94,7 +94,7 @@ describe('Test video blacklist API validators', function () {
94 }) 94 })
95 95
96 it('Should fail with a non admin user', async function () { 96 it('Should fail with a non admin user', async function () {
97 const path = basePath + server.video.id 97 const path = basePath + server.video.id + '/blacklist'
98 98
99 await request(server.url) 99 await request(server.url)
100 .delete(path) 100 .delete(path)
@@ -104,7 +104,7 @@ describe('Test video blacklist API validators', function () {
104 }) 104 })
105 105
106 it('Should fail with an incorrect id', async function () { 106 it('Should fail with an incorrect id', async function () {
107 const path = basePath + 'foobar' 107 const path = basePath + 'foobar/blacklist'
108 108
109 await request(server.url) 109 await request(server.url)
110 .delete(path) 110 .delete(path)
@@ -115,7 +115,7 @@ describe('Test video blacklist API validators', function () {
115 115
116 it('Should fail with a not blacklisted video', async function () { 116 it('Should fail with a not blacklisted video', async function () {
117 // The video was not added to the blacklist so it should fail 117 // The video was not added to the blacklist so it should fail
118 const path = basePath + server.video.id 118 const path = basePath + server.video.id + '/blacklist'
119 119
120 await request(server.url) 120 await request(server.url)
121 .delete(path) 121 .delete(path)
@@ -126,7 +126,7 @@ describe('Test video blacklist API validators', function () {
126 }) 126 })
127 127
128 describe('When listing videos in blacklist', function () { 128 describe('When listing videos in blacklist', function () {
129 const basePath = '/api/v1/blacklist/' 129 const basePath = '/api/v1/videos/blacklist/'
130 130
131 it('Should fail with a non authenticated user', async function () { 131 it('Should fail with a non authenticated user', async function () {
132 const path = basePath 132 const path = basePath
diff --git a/server/tests/utils/video-blacklist.ts b/server/tests/utils/video-blacklist.ts
index 5729d13d8..3a499f46a 100644
--- a/server/tests/utils/video-blacklist.ts
+++ b/server/tests/utils/video-blacklist.ts
@@ -11,7 +11,7 @@ function addVideoToBlacklist (url: string, token: string, videoId: number, speci
11} 11}
12 12
13function removeVideoFromBlacklist (url: string, token: string, videoId: number, specialStatus = 204) { 13function removeVideoFromBlacklist (url: string, token: string, videoId: number, specialStatus = 204) {
14 const path = '/api/v1/blacklist/' + videoId 14 const path = '/api/v1/videos/' + videoId + '/blacklist'
15 15
16 return request(url) 16 return request(url)
17 .delete(path) 17 .delete(path)
@@ -21,7 +21,7 @@ function removeVideoFromBlacklist (url: string, token: string, videoId: number,
21} 21}
22 22
23function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) { 23function getBlacklistedVideosList (url: string, token: string, specialStatus = 200) {
24 const path = '/api/v1/blacklist/' 24 const path = '/api/v1/videos/blacklist/'
25 25
26 return request(url) 26 return request(url)
27 .get(path) 27 .get(path)
@@ -33,7 +33,7 @@ function getBlacklistedVideosList (url: string, token: string, specialStatus = 2
33} 33}
34 34
35function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) { 35function getSortedBlacklistedVideosList (url: string, token: string, sort: string, specialStatus = 200) {
36 const path = '/api/v1/blacklist/' 36 const path = '/api/v1/videos/blacklist/'
37 37
38 return request(url) 38 return request(url)
39 .get(path) 39 .get(path)