This commit is contained in:
Chocobozzz 2020-08-06 16:14:58 +02:00 committed by Chocobozzz
parent d88c9eb9db
commit a02b93ce75
13 changed files with 37 additions and 25 deletions

View File

@ -6,6 +6,7 @@ import { USER_ROLE_LABELS } from '@shared/core-utils/users'
import { ServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models'
@Directive()
// tslint:disable-next-line: directive-class-suffix
export abstract class UserEdit extends FormReactive implements OnInit {
videoQuotaOptions: { value: string, label: string, disabled?: boolean }[] = []
videoQuotaDailyOptions: { value: string, label: string, disabled?: boolean }[] = []

View File

@ -1,5 +1,5 @@
import { Subject } from 'rxjs'
import { debounceTime, flatMap } from 'rxjs/operators'
import { debounceTime, mergeMap } from 'rxjs/operators'
import { Component, OnInit } from '@angular/core'
import { AuthService, ComponentPagination, ConfirmService, Notifier, User } from '@app/core'
import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
@ -95,7 +95,7 @@ export class MyAccountVideoPlaylistsComponent implements OnInit {
private loadVideoPlaylists (reset = false) {
this.authService.userInformationLoaded
.pipe(flatMap(() => {
.pipe(mergeMap(() => {
return this.videoPlaylistService.listAccountPlaylists(this.user.account, this.pagination, '-updatedAt', this.videoPlaylistsSearch)
}))
.subscribe(res => {

View File

@ -84,11 +84,11 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca
channelId: this.firstStepChannelId
}
this.loadingBar.start()
this.loadingBar.useRef().start()
this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe(
res => {
this.loadingBar.complete()
this.loadingBar.useRef().complete()
this.firstStepDone.emit(res.video.name)
this.isImportingVideo = false
this.hasImportedVideo = true
@ -105,7 +105,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca
},
err => {
this.loadingBar.complete()
this.loadingBar.useRef().complete()
this.isImportingVideo = false
this.firstStepError.emit()
this.notifier.error(err.message)

View File

@ -71,7 +71,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
channelId: this.firstStepChannelId
}
this.loadingBar.start()
this.loadingBar.useRef().start()
this.videoImportService
.importVideoUrl(this.targetUrl, videoUpdate)
@ -86,7 +86,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
)
.subscribe(
({ video, videoCaptions }) => {
this.loadingBar.complete()
this.loadingBar.useRef().complete()
this.firstStepDone.emit(video.name)
this.isImportingVideo = false
this.hasImportedVideo = true
@ -115,7 +115,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
},
err => {
this.loadingBar.complete()
this.loadingBar.useRef().complete()
this.isImportingVideo = false
this.firstStepError.emit()
this.notifier.error(err.message)

View File

@ -1,5 +1,5 @@
import { catchError, switchMap, tap } from 'rxjs/operators'
import { EventEmitter, OnInit, Directive } from '@angular/core'
import { Directive, EventEmitter, OnInit } from '@angular/core'
import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core'
import { populateAsyncUserVideoChannels } from '@app/helpers'
import { FormReactive } from '@app/shared/shared-forms'
@ -8,6 +8,7 @@ import { LoadingBarService } from '@ngx-loading-bar/core'
import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
@Directive()
// tslint:disable-next-line: directive-class-suffix
export abstract class VideoSend extends FormReactive implements OnInit {
userVideoChannels: { id: number, label: string, support: string }[] = []
videoPrivacies: VideoConstant<VideoPrivacy>[] = []
@ -56,15 +57,15 @@ export abstract class VideoSend extends FormReactive implements OnInit {
}
protected updateVideoAndCaptions (video: VideoEdit) {
this.loadingBar.start()
this.loadingBar.useRef().start()
return this.videoService.updateVideo(video)
.pipe(
// Then update captions
switchMap(() => this.videoCaptionService.updateCaptions(video.id, this.videoCaptions)),
tap(() => this.loadingBar.complete()),
tap(() => this.loadingBar.useRef().complete()),
catchError(err => {
this.loadingBar.complete()
this.loadingBar.useRef().complete()
throw err
})
)

View File

@ -101,7 +101,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
this.video.patch(this.form.value)
this.loadingBar.start()
this.loadingBar.useRef().start()
this.isUpdatingVideo = true
// Update the video
@ -114,13 +114,13 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
() => {
this.updateDone = true
this.isUpdatingVideo = false
this.loadingBar.complete()
this.loadingBar.useRef().complete()
this.notifier.success(this.i18n('Video updated.'))
this.router.navigate([ '/videos/watch', this.video.uuid ])
},
err => {
this.loadingBar.complete()
this.loadingBar.useRef().complete()
this.isUpdatingVideo = false
this.notifier.error(err.message)
console.error(err)

View File

@ -1,7 +1,7 @@
import { Observable, of } from 'rxjs'
import { map } from 'rxjs/operators'
import { User } from '@app/core/users/user.model'
import { peertubeLocalStorage } from '@app/helpers/peertube-web-storage'
import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
import { hasUserRight } from '@shared/core-utils/users'
import {
MyUser as ServerMyUserModel,
@ -12,7 +12,7 @@ import {
UserRole,
UserVideoQuota
} from '@shared/models'
import { TokenOptions, Tokens } from '../../../root-helpers/pure-auth-user.model'
import { TokenOptions, Tokens } from '@root-helpers/pure-auth-user.model'
export class AuthUser extends User implements ServerMyUserModel {
tokens: Tokens

View File

@ -7,6 +7,7 @@ import { AccountBlock } from './account-block.model'
import { BlocklistComponentType, BlocklistService } from './blocklist.service'
@Directive()
// tslint:disable-next-line: directive-class-suffix
export class GenericAccountBlocklistComponent extends RestTable implements OnInit {
// @ts-ignore: "Abstract methods can only appear within an abstract class"
abstract mode: BlocklistComponentType

View File

@ -1,12 +1,13 @@
import { SortMeta } from 'primeng/api'
import { OnInit, ViewChild, Directive } from '@angular/core'
import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component'
import { Directive, OnInit, ViewChild } from '@angular/core'
import { Notifier, RestPagination, RestTable } from '@app/core'
import { BatchDomainsModalComponent } from '@app/shared/shared-moderation/batch-domains-modal.component'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { ServerBlock } from '@shared/models'
import { BlocklistComponentType, BlocklistService } from './blocklist.service'
@Directive()
// tslint:disable-next-line: directive-class-suffix
export class GenericServerBlocklistComponent extends RestTable implements OnInit {
@ViewChild('batchDomainsModal') batchDomainsModal: BatchDomainsModalComponent

View File

@ -1,6 +1,6 @@
import { fromEvent, Observable, Subject, Subscription } from 'rxjs'
import { debounceTime, switchMap, tap } from 'rxjs/operators'
import { OnDestroy, OnInit, Directive } from '@angular/core'
import { Directive, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import {
AuthService,
@ -31,6 +31,7 @@ enum GroupDate {
}
@Directive()
// tslint:disable-next-line: directive-class-suffix
export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableForReuseHook {
pagination: ComponentPaginationLight = {
currentPage: 1,

View File

@ -4,7 +4,7 @@ import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
import { PluginManager } from '../../lib/plugins/plugin-manager'
import { isBooleanValid, isSafePath, toBooleanOrNull, exists } from '../../helpers/custom-validators/misc'
import { isBooleanValid, isSafePath, toBooleanOrNull, exists, toIntOrNull } from '../../helpers/custom-validators/misc'
import { PluginModel } from '../../models/server/plugin'
import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model'
import { PluginType } from '../../../shared/models/plugins/plugin.type'
@ -75,6 +75,7 @@ const pluginStaticDirectoryValidator = [
const listPluginsValidator = [
query('pluginType')
.optional()
.customSanitizer(toIntOrNull)
.custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
query('uninstalled')
.optional()
@ -165,6 +166,7 @@ const listAvailablePluginsValidator = [
.exists().withMessage('Should have a valid search'),
query('pluginType')
.optional()
.customSanitizer(toIntOrNull)
.custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
query('currentPeerTubeEngine')
.optional()

View File

@ -1,10 +1,10 @@
import * as express from 'express'
import { body, param, query } from 'express-validator'
import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
import { logger } from '../../../helpers/logger'
import { areValidationErrors } from '../utils'
import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
import { logger } from '../../../helpers/logger'
import { doesVideoBlacklistExist, doesVideoExist } from '../../../helpers/middlewares'
import { areValidationErrors } from '../utils'
const videosBlacklistRemoveValidator = [
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
@ -67,7 +67,8 @@ const videosBlacklistUpdateValidator = [
const videosBlacklistFiltersValidator = [
query('type')
.optional()
.optional()
.customSanitizer(toIntOrNull)
.custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'),
query('search')
.optional()

View File

@ -421,6 +421,10 @@ describe('Test abuses API validators', function () {
it('Should fail when creating abuse message of a remote abuse', async function () {
await addAbuseMessage(server.url, server.accessToken, remoteAbuseId, 'message', 400)
})
after(async function () {
await cleanupTests([ anotherServer ])
})
})
after(async function () {