aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts1
-rw-r--r--client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts4
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts6
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts6
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-send.ts9
-rw-r--r--client/src/app/+videos/+video-edit/video-update.component.ts6
-rw-r--r--client/src/app/core/auth/auth-user.model.ts4
-rw-r--r--client/src/app/shared/shared-moderation/account-blocklist.component.ts1
-rw-r--r--client/src/app/shared/shared-moderation/server-blocklist.component.ts5
-rw-r--r--client/src/app/shared/shared-video-miniature/abstract-video-list.ts3
-rw-r--r--server/middlewares/validators/plugins.ts4
-rw-r--r--server/middlewares/validators/videos/video-blacklist.ts9
-rw-r--r--server/tests/api/check-params/abuses.ts4
13 files changed, 37 insertions, 25 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts
index bdbb10814..787f4b689 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/users/user-edit/user-edit.ts
@@ -6,6 +6,7 @@ import { USER_ROLE_LABELS } from '@shared/core-utils/users'
6import { ServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models' 6import { ServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models'
7 7
8@Directive() 8@Directive()
9// tslint:disable-next-line: directive-class-suffix
9export abstract class UserEdit extends FormReactive implements OnInit { 10export abstract class UserEdit extends FormReactive implements OnInit {
10 videoQuotaOptions: { value: string, label: string, disabled?: boolean }[] = [] 11 videoQuotaOptions: { value: string, label: string, disabled?: boolean }[] = []
11 videoQuotaDailyOptions: { value: string, label: string, disabled?: boolean }[] = [] 12 videoQuotaDailyOptions: { value: string, label: string, disabled?: boolean }[] = []
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts
index 668a23d8f..ba95b6c8b 100644
--- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts
+++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlists.component.ts
@@ -1,5 +1,5 @@
1import { Subject } from 'rxjs' 1import { Subject } from 'rxjs'
2import { debounceTime, flatMap } from 'rxjs/operators' 2import { debounceTime, mergeMap } from 'rxjs/operators'
3import { Component, OnInit } from '@angular/core' 3import { Component, OnInit } from '@angular/core'
4import { AuthService, ComponentPagination, ConfirmService, Notifier, User } from '@app/core' 4import { AuthService, ComponentPagination, ConfirmService, Notifier, User } from '@app/core'
5import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' 5import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
@@ -95,7 +95,7 @@ export class MyAccountVideoPlaylistsComponent implements OnInit {
95 95
96 private loadVideoPlaylists (reset = false) { 96 private loadVideoPlaylists (reset = false) {
97 this.authService.userInformationLoaded 97 this.authService.userInformationLoaded
98 .pipe(flatMap(() => { 98 .pipe(mergeMap(() => {
99 return this.videoPlaylistService.listAccountPlaylists(this.user.account, this.pagination, '-updatedAt', this.videoPlaylistsSearch) 99 return this.videoPlaylistService.listAccountPlaylists(this.user.account, this.pagination, '-updatedAt', this.videoPlaylistsSearch)
100 })) 100 }))
101 .subscribe(res => { 101 .subscribe(res => {
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
index 538a187a8..3a8e6eecc 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
@@ -84,11 +84,11 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca
84 channelId: this.firstStepChannelId 84 channelId: this.firstStepChannelId
85 } 85 }
86 86
87 this.loadingBar.start() 87 this.loadingBar.useRef().start()
88 88
89 this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe( 89 this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe(
90 res => { 90 res => {
91 this.loadingBar.complete() 91 this.loadingBar.useRef().complete()
92 this.firstStepDone.emit(res.video.name) 92 this.firstStepDone.emit(res.video.name)
93 this.isImportingVideo = false 93 this.isImportingVideo = false
94 this.hasImportedVideo = true 94 this.hasImportedVideo = true
@@ -105,7 +105,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca
105 }, 105 },
106 106
107 err => { 107 err => {
108 this.loadingBar.complete() 108 this.loadingBar.useRef().complete()
109 this.isImportingVideo = false 109 this.isImportingVideo = false
110 this.firstStepError.emit() 110 this.firstStepError.emit()
111 this.notifier.error(err.message) 111 this.notifier.error(err.message)
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
index 6508eef7e..da25663d7 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
@@ -71,7 +71,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
71 channelId: this.firstStepChannelId 71 channelId: this.firstStepChannelId
72 } 72 }
73 73
74 this.loadingBar.start() 74 this.loadingBar.useRef().start()
75 75
76 this.videoImportService 76 this.videoImportService
77 .importVideoUrl(this.targetUrl, videoUpdate) 77 .importVideoUrl(this.targetUrl, videoUpdate)
@@ -86,7 +86,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
86 ) 86 )
87 .subscribe( 87 .subscribe(
88 ({ video, videoCaptions }) => { 88 ({ video, videoCaptions }) => {
89 this.loadingBar.complete() 89 this.loadingBar.useRef().complete()
90 this.firstStepDone.emit(video.name) 90 this.firstStepDone.emit(video.name)
91 this.isImportingVideo = false 91 this.isImportingVideo = false
92 this.hasImportedVideo = true 92 this.hasImportedVideo = true
@@ -115,7 +115,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
115 }, 115 },
116 116
117 err => { 117 err => {
118 this.loadingBar.complete() 118 this.loadingBar.useRef().complete()
119 this.isImportingVideo = false 119 this.isImportingVideo = false
120 this.firstStepError.emit() 120 this.firstStepError.emit()
121 this.notifier.error(err.message) 121 this.notifier.error(err.message)
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts
index 5d11ba7ce..2e658dfae 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts
@@ -1,5 +1,5 @@
1import { catchError, switchMap, tap } from 'rxjs/operators' 1import { catchError, switchMap, tap } from 'rxjs/operators'
2import { EventEmitter, OnInit, Directive } from '@angular/core' 2import { Directive, EventEmitter, OnInit } from '@angular/core'
3import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core' 3import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core'
4import { populateAsyncUserVideoChannels } from '@app/helpers' 4import { populateAsyncUserVideoChannels } from '@app/helpers'
5import { FormReactive } from '@app/shared/shared-forms' 5import { FormReactive } from '@app/shared/shared-forms'
@@ -8,6 +8,7 @@ import { LoadingBarService } from '@ngx-loading-bar/core'
8import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' 8import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
9 9
10@Directive() 10@Directive()
11// tslint:disable-next-line: directive-class-suffix
11export abstract class VideoSend extends FormReactive implements OnInit { 12export abstract class VideoSend extends FormReactive implements OnInit {
12 userVideoChannels: { id: number, label: string, support: string }[] = [] 13 userVideoChannels: { id: number, label: string, support: string }[] = []
13 videoPrivacies: VideoConstant<VideoPrivacy>[] = [] 14 videoPrivacies: VideoConstant<VideoPrivacy>[] = []
@@ -56,15 +57,15 @@ export abstract class VideoSend extends FormReactive implements OnInit {
56 } 57 }
57 58
58 protected updateVideoAndCaptions (video: VideoEdit) { 59 protected updateVideoAndCaptions (video: VideoEdit) {
59 this.loadingBar.start() 60 this.loadingBar.useRef().start()
60 61
61 return this.videoService.updateVideo(video) 62 return this.videoService.updateVideo(video)
62 .pipe( 63 .pipe(
63 // Then update captions 64 // Then update captions
64 switchMap(() => this.videoCaptionService.updateCaptions(video.id, this.videoCaptions)), 65 switchMap(() => this.videoCaptionService.updateCaptions(video.id, this.videoCaptions)),
65 tap(() => this.loadingBar.complete()), 66 tap(() => this.loadingBar.useRef().complete()),
66 catchError(err => { 67 catchError(err => {
67 this.loadingBar.complete() 68 this.loadingBar.useRef().complete()
68 throw err 69 throw err
69 }) 70 })
70 ) 71 )
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts
index 7bd6eb553..581199d65 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.ts
+++ b/client/src/app/+videos/+video-edit/video-update.component.ts
@@ -101,7 +101,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
101 101
102 this.video.patch(this.form.value) 102 this.video.patch(this.form.value)
103 103
104 this.loadingBar.start() 104 this.loadingBar.useRef().start()
105 this.isUpdatingVideo = true 105 this.isUpdatingVideo = true
106 106
107 // Update the video 107 // Update the video
@@ -114,13 +114,13 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
114 () => { 114 () => {
115 this.updateDone = true 115 this.updateDone = true
116 this.isUpdatingVideo = false 116 this.isUpdatingVideo = false
117 this.loadingBar.complete() 117 this.loadingBar.useRef().complete()
118 this.notifier.success(this.i18n('Video updated.')) 118 this.notifier.success(this.i18n('Video updated.'))
119 this.router.navigate([ '/videos/watch', this.video.uuid ]) 119 this.router.navigate([ '/videos/watch', this.video.uuid ])
120 }, 120 },
121 121
122 err => { 122 err => {
123 this.loadingBar.complete() 123 this.loadingBar.useRef().complete()
124 this.isUpdatingVideo = false 124 this.isUpdatingVideo = false
125 this.notifier.error(err.message) 125 this.notifier.error(err.message)
126 console.error(err) 126 console.error(err)
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts
index 5efc6e1ab..5679d28a9 100644
--- a/client/src/app/core/auth/auth-user.model.ts
+++ b/client/src/app/core/auth/auth-user.model.ts
@@ -1,7 +1,7 @@
1import { Observable, of } from 'rxjs' 1import { Observable, of } from 'rxjs'
2import { map } from 'rxjs/operators' 2import { map } from 'rxjs/operators'
3import { User } from '@app/core/users/user.model' 3import { User } from '@app/core/users/user.model'
4import { peertubeLocalStorage } from '@app/helpers/peertube-web-storage' 4import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
5import { hasUserRight } from '@shared/core-utils/users' 5import { hasUserRight } from '@shared/core-utils/users'
6import { 6import {
7 MyUser as ServerMyUserModel, 7 MyUser as ServerMyUserModel,
@@ -12,7 +12,7 @@ import {
12 UserRole, 12 UserRole,
13 UserVideoQuota 13 UserVideoQuota
14} from '@shared/models' 14} from '@shared/models'
15import { TokenOptions, Tokens } from '../../../root-helpers/pure-auth-user.model' 15import { TokenOptions, Tokens } from '@root-helpers/pure-auth-user.model'
16 16
17export class AuthUser extends User implements ServerMyUserModel { 17export class AuthUser extends User implements ServerMyUserModel {
18 tokens: Tokens 18 tokens: Tokens
diff --git a/client/src/app/shared/shared-moderation/account-blocklist.component.ts b/client/src/app/shared/shared-moderation/account-blocklist.component.ts
index 11e554978..a5a3c27cd 100644
--- a/client/src/app/shared/shared-moderation/account-blocklist.component.ts
+++ b/client/src/app/shared/shared-moderation/account-blocklist.component.ts
@@ -7,6 +7,7 @@ import { AccountBlock } from './account-block.model'
7import { BlocklistComponentType, BlocklistService } from './blocklist.service' 7import { BlocklistComponentType, BlocklistService } from './blocklist.service'
8 8
9@Directive() 9@Directive()
10// tslint:disable-next-line: directive-class-suffix
10export class GenericAccountBlocklistComponent extends RestTable implements OnInit { 11export class GenericAccountBlocklistComponent extends RestTable implements OnInit {
11 // @ts-ignore: "Abstract methods can only appear within an abstract class" 12 // @ts-ignore: "Abstract methods can only appear within an abstract class"
12 abstract mode: BlocklistComponentType 13 abstract mode: BlocklistComponentType
diff --git a/client/src/app/shared/shared-moderation/server-blocklist.component.ts b/client/src/app/shared/shared-moderation/server-blocklist.component.ts
index 694b03762..8f65cdb71 100644
--- a/client/src/app/shared/shared-moderation/server-blocklist.component.ts
+++ b/client/src/app/shared/shared-moderation/server-blocklist.component.ts
@@ -1,12 +1,13 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { OnInit, ViewChild, Directive } from '@angular/core' 2import { Directive, OnInit, ViewChild } from '@angular/core'
3import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component'
4import { Notifier, RestPagination, RestTable } from '@app/core' 3import { Notifier, RestPagination, RestTable } from '@app/core'
4import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component'
5import { I18n } from '@ngx-translate/i18n-polyfill' 5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { ServerBlock } from '@shared/models' 6import { ServerBlock } from '@shared/models'
7import { BlocklistComponentType, BlocklistService } from './blocklist.service' 7import { BlocklistComponentType, BlocklistService } from './blocklist.service'
8 8
9@Directive() 9@Directive()
10// tslint:disable-next-line: directive-class-suffix
10export class GenericServerBlocklistComponent extends RestTable implements OnInit { 11export class GenericServerBlocklistComponent extends RestTable implements OnInit {
11 @ViewChild('batchDomainsModal') batchDomainsModal: BatchDomainsModalComponent 12 @ViewChild('batchDomainsModal') batchDomainsModal: BatchDomainsModalComponent
12 13
diff --git a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
index 405af5fa6..e18002b74 100644
--- a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
+++ b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
@@ -1,6 +1,6 @@
1import { fromEvent, Observable, Subject, Subscription } from 'rxjs' 1import { fromEvent, Observable, Subject, Subscription } from 'rxjs'
2import { debounceTime, switchMap, tap } from 'rxjs/operators' 2import { debounceTime, switchMap, tap } from 'rxjs/operators'
3import { OnDestroy, OnInit, Directive } from '@angular/core' 3import { Directive, OnDestroy, OnInit } from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router' 4import { ActivatedRoute, Router } from '@angular/router'
5import { 5import {
6 AuthService, 6 AuthService,
@@ -31,6 +31,7 @@ enum GroupDate {
31} 31}
32 32
33@Directive() 33@Directive()
34// tslint:disable-next-line: directive-class-suffix
34export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableForReuseHook { 35export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableForReuseHook {
35 pagination: ComponentPaginationLight = { 36 pagination: ComponentPaginationLight = {
36 currentPage: 1, 37 currentPage: 1,
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index 2cb49ec43..cba261dc0 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -4,7 +4,7 @@ import { logger } from '../../helpers/logger'
4import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
5import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' 5import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
6import { PluginManager } from '../../lib/plugins/plugin-manager' 6import { PluginManager } from '../../lib/plugins/plugin-manager'
7import { isBooleanValid, isSafePath, toBooleanOrNull, exists } from '../../helpers/custom-validators/misc' 7import { isBooleanValid, isSafePath, toBooleanOrNull, exists, toIntOrNull } from '../../helpers/custom-validators/misc'
8import { PluginModel } from '../../models/server/plugin' 8import { PluginModel } from '../../models/server/plugin'
9import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' 9import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model'
10import { PluginType } from '../../../shared/models/plugins/plugin.type' 10import { PluginType } from '../../../shared/models/plugins/plugin.type'
@@ -75,6 +75,7 @@ const pluginStaticDirectoryValidator = [
75const listPluginsValidator = [ 75const listPluginsValidator = [
76 query('pluginType') 76 query('pluginType')
77 .optional() 77 .optional()
78 .customSanitizer(toIntOrNull)
78 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), 79 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
79 query('uninstalled') 80 query('uninstalled')
80 .optional() 81 .optional()
@@ -165,6 +166,7 @@ const listAvailablePluginsValidator = [
165 .exists().withMessage('Should have a valid search'), 166 .exists().withMessage('Should have a valid search'),
166 query('pluginType') 167 query('pluginType')
167 .optional() 168 .optional()
169 .customSanitizer(toIntOrNull)
168 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), 170 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
169 query('currentPeerTubeEngine') 171 query('currentPeerTubeEngine')
170 .optional() 172 .optional()
diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts
index 4bd6a8333..808fefc25 100644
--- a/server/middlewares/validators/videos/video-blacklist.ts
+++ b/server/middlewares/validators/videos/video-blacklist.ts
@@ -1,10 +1,10 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' 3import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
4import { logger } from '../../../helpers/logger'
5import { areValidationErrors } from '../utils'
6import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' 4import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
5import { logger } from '../../../helpers/logger'
7import { doesVideoBlacklistExist, doesVideoExist } from '../../../helpers/middlewares' 6import { doesVideoBlacklistExist, doesVideoExist } from '../../../helpers/middlewares'
7import { areValidationErrors } from '../utils'
8 8
9const videosBlacklistRemoveValidator = [ 9const videosBlacklistRemoveValidator = [
10 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), 10 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
@@ -67,7 +67,8 @@ const videosBlacklistUpdateValidator = [
67 67
68const videosBlacklistFiltersValidator = [ 68const videosBlacklistFiltersValidator = [
69 query('type') 69 query('type')
70 .optional() 70 .optional()
71 .customSanitizer(toIntOrNull)
71 .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'), 72 .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'),
72 query('search') 73 query('search')
73 .optional() 74 .optional()
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 1f040bbcf..8dadd9922 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -421,6 +421,10 @@ describe('Test abuses API validators', function () {
421 it('Should fail when creating abuse message of a remote abuse', async function () { 421 it('Should fail when creating abuse message of a remote abuse', async function () {
422 await addAbuseMessage(server.url, server.accessToken, remoteAbuseId, 'message', 400) 422 await addAbuseMessage(server.url, server.accessToken, remoteAbuseId, 'message', 400)
423 }) 423 })
424
425 after(async function () {
426 await cleanupTests([ anotherServer ])
427 })
424 }) 428 })
425 429
426 after(async function () { 430 after(async function () {