mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Move middleware utils in middlewares
helpers modules should not import models
This commit is contained in:
parent
5e08989ede
commit
10363c74c1
@ -14,8 +14,7 @@ import { VideoChannelsSearchQuery, VideosSearchQuery } from '../../../shared/mod
|
||||
import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { getFormattedObjects } from '../../helpers/utils'
|
||||
import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger'
|
||||
import { getOrCreateAPActor } from '../../lib/activitypub/actors'
|
||||
import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../lib/activitypub/actors'
|
||||
import {
|
||||
asyncMiddleware,
|
||||
commonVideosFiltersValidator,
|
||||
|
@ -1,9 +1,5 @@
|
||||
import * as express from 'express'
|
||||
import validator from 'validator'
|
||||
import { VideoCommentModel } from '@server/models/video/video-comment'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
import { MVideoId } from '@server/types/models'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const VIDEO_COMMENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_COMMENTS
|
||||
|
||||
@ -11,74 +7,8 @@ function isValidVideoCommentText (value: string) {
|
||||
return value === null || validator.isLength(value, VIDEO_COMMENTS_CONSTRAINTS_FIELDS.TEXT)
|
||||
}
|
||||
|
||||
async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) {
|
||||
const id = parseInt(idArg + '', 10)
|
||||
const videoComment = await VideoCommentModel.loadById(id)
|
||||
|
||||
if (!videoComment) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video comment thread not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (videoComment.videoId !== video.id) {
|
||||
res.fail({ message: 'Video comment is not associated to this video.' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (videoComment.inReplyToCommentId !== null) {
|
||||
res.fail({ message: 'Video comment is not a thread.' })
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoCommentThread = videoComment
|
||||
return true
|
||||
}
|
||||
|
||||
async function doesVideoCommentExist (idArg: number | string, video: MVideoId, res: express.Response) {
|
||||
const id = parseInt(idArg + '', 10)
|
||||
const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id)
|
||||
|
||||
if (!videoComment) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video comment thread not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (videoComment.videoId !== video.id) {
|
||||
res.fail({ message: 'Video comment is not associated to this video.' })
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoCommentFull = videoComment
|
||||
return true
|
||||
}
|
||||
|
||||
async function doesCommentIdExist (idArg: number | string, res: express.Response) {
|
||||
const id = parseInt(idArg + '', 10)
|
||||
const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id)
|
||||
|
||||
if (!videoComment) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video comment thread not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoCommentFull = videoComment
|
||||
return true
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
isValidVideoCommentText,
|
||||
doesVideoCommentThreadExist,
|
||||
doesVideoCommentExist,
|
||||
doesCommentIdExist
|
||||
isValidVideoCommentText
|
||||
}
|
||||
|
@ -2,9 +2,6 @@ import 'multer'
|
||||
import validator from 'validator'
|
||||
import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants'
|
||||
import { exists, isFileValid } from './misc'
|
||||
import * as express from 'express'
|
||||
import { VideoImportModel } from '../../models/video/video-import'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
function isVideoImportTargetUrlValid (url: string) {
|
||||
const isURLOptions = {
|
||||
@ -32,26 +29,10 @@ function isVideoImportTorrentFile (files: { [ fieldname: string ]: Express.Multe
|
||||
return isFileValid(files, videoTorrentImportRegex, 'torrentfile', CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_FILE.FILE_SIZE.max, true)
|
||||
}
|
||||
|
||||
async function doesVideoImportExist (id: number, res: express.Response) {
|
||||
const videoImport = await VideoImportModel.loadAndPopulateVideo(id)
|
||||
|
||||
if (!videoImport) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video import not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoImport = videoImport
|
||||
return true
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
isVideoImportStateValid,
|
||||
isVideoImportTargetUrlValid,
|
||||
doesVideoImportExist,
|
||||
isVideoImportTorrentFile
|
||||
}
|
||||
|
@ -1,26 +1,9 @@
|
||||
import { Response } from 'express'
|
||||
import { VideoChangeOwnershipModel } from '../../models/video/video-change-ownership'
|
||||
import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership'
|
||||
import { MUserId } from '@server/types/models'
|
||||
import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
export async function doesChangeVideoOwnershipExist (idArg: number | string, res: Response) {
|
||||
const id = parseInt(idArg + '', 10)
|
||||
const videoChangeOwnership = await VideoChangeOwnershipModel.load(id)
|
||||
|
||||
if (!videoChangeOwnership) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video change ownership not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoChangeOwnership = videoChangeOwnership
|
||||
return true
|
||||
}
|
||||
|
||||
export function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) {
|
||||
function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) {
|
||||
if (videoChangeOwnership.NextOwner.userId === user.id) {
|
||||
return true
|
||||
}
|
||||
@ -31,3 +14,7 @@ export function checkUserCanTerminateOwnershipChange (user: MUserId, videoChange
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
export {
|
||||
checkUserCanTerminateOwnershipChange
|
||||
}
|
||||
|
@ -1,66 +1,7 @@
|
||||
import { Response } from 'express'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
import {
|
||||
isStreamingPlaylist,
|
||||
MStreamingPlaylistVideo,
|
||||
MVideo,
|
||||
MVideoAccountLightBlacklistAllFiles,
|
||||
MVideoFullLight,
|
||||
MVideoIdThumbnail,
|
||||
MVideoImmutable,
|
||||
MVideoThumbnail,
|
||||
MVideoWithRights
|
||||
} from '@server/types/models'
|
||||
import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models'
|
||||
import { VideoPrivacy, VideoState } from '@shared/models'
|
||||
import { VideoModel } from '../models/video/video'
|
||||
|
||||
type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes'
|
||||
|
||||
function fetchVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight>
|
||||
function fetchVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable>
|
||||
function fetchVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail>
|
||||
function fetchVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise<MVideoWithRights>
|
||||
function fetchVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoIdThumbnail>
|
||||
function fetchVideo (
|
||||
id: number | string,
|
||||
fetchType: VideoFetchType,
|
||||
userId?: number
|
||||
): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable>
|
||||
function fetchVideo (
|
||||
id: number | string,
|
||||
fetchType: VideoFetchType,
|
||||
userId?: number
|
||||
): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> {
|
||||
if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId)
|
||||
|
||||
if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id)
|
||||
|
||||
if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id)
|
||||
|
||||
if (fetchType === 'only-video') return VideoModel.load(id)
|
||||
|
||||
if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id)
|
||||
}
|
||||
|
||||
type VideoFetchByUrlType = 'all' | 'only-video' | 'only-immutable-attributes'
|
||||
|
||||
function fetchVideoByUrl (url: string, fetchType: 'all'): Promise<MVideoAccountLightBlacklistAllFiles>
|
||||
function fetchVideoByUrl (url: string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable>
|
||||
function fetchVideoByUrl (url: string, fetchType: 'only-video'): Promise<MVideoThumbnail>
|
||||
function fetchVideoByUrl (
|
||||
url: string,
|
||||
fetchType: VideoFetchByUrlType
|
||||
): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable>
|
||||
function fetchVideoByUrl (
|
||||
url: string,
|
||||
fetchType: VideoFetchByUrlType
|
||||
): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> {
|
||||
if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url)
|
||||
|
||||
if (fetchType === 'only-immutable-attributes') return VideoModel.loadByUrlImmutableAttributes(url)
|
||||
|
||||
if (fetchType === 'only-video') return VideoModel.loadByUrl(url)
|
||||
}
|
||||
|
||||
function getVideoWithAttributes (res: Response) {
|
||||
return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights
|
||||
@ -100,11 +41,7 @@ function getExtFromMimetype (mimeTypes: { [id: string]: string | string[] }, mim
|
||||
}
|
||||
|
||||
export {
|
||||
VideoFetchType,
|
||||
VideoFetchByUrlType,
|
||||
fetchVideo,
|
||||
getVideoWithAttributes,
|
||||
fetchVideoByUrl,
|
||||
extractVideo,
|
||||
getExtFromMimetype,
|
||||
isStateForFederation,
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
import { checkUrlsSameHost, getAPId } from '@server/helpers/activitypub'
|
||||
import { ActorFetchByUrlType, fetchActorByUrl } from '@server/helpers/actor'
|
||||
import { retryTransactionWrapper } from '@server/helpers/database-utils'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { JobQueue } from '@server/lib/job-queue'
|
||||
import { ActorFetchByUrlType, fetchActorByUrl } from '@server/lib/model-loaders'
|
||||
import { MActor, MActorAccountChannelId, MActorAccountChannelIdActor, MActorAccountId, MActorFullActor } from '@server/types/models'
|
||||
import { ActivityPubActor } from '@shared/models'
|
||||
import { refreshActorIfNeeded } from './refresh'
|
||||
|
@ -3,3 +3,4 @@ export * from './image'
|
||||
export * from './keys'
|
||||
export * from './refresh'
|
||||
export * from './updater'
|
||||
export * from './webfinger'
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { ActorFetchByUrlType } from '@server/helpers/actor'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { PeerTubeRequestError } from '@server/helpers/requests'
|
||||
import { getUrlFromWebfinger } from '@server/helpers/webfinger'
|
||||
import { ActorFetchByUrlType } from '@server/lib/model-loaders'
|
||||
import { ActorModel } from '@server/models/actor/actor'
|
||||
import { MActorAccountChannelId, MActorFull } from '@server/types/models'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
import { fetchRemoteActor } from './shared'
|
||||
import { APActorUpdater } from './updater'
|
||||
import { getUrlFromWebfinger } from './webfinger'
|
||||
|
||||
async function refreshActorIfNeeded <T extends MActorFull | MActorAccountChannelId> (
|
||||
actorArg: T,
|
||||
|
@ -1,3 +1,3 @@
|
||||
export * from './creator'
|
||||
export * from './url-to-object'
|
||||
export * from './object-to-model-attributes'
|
||||
export * from './url-to-object'
|
||||
|
@ -1,10 +1,10 @@
|
||||
import * as WebFinger from 'webfinger.js'
|
||||
import { WebFingerData } from '../../shared'
|
||||
import { WEBSERVER } from '../initializers/constants'
|
||||
import { ActorModel } from '../models/actor/actor'
|
||||
import { MActorFull } from '../types/models'
|
||||
import { isTestInstance } from './core-utils'
|
||||
import { isActivityPubUrlValid } from './custom-validators/activitypub/misc'
|
||||
import { isTestInstance } from '@server/helpers/core-utils'
|
||||
import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
|
||||
import { WEBSERVER } from '@server/initializers/constants'
|
||||
import { ActorModel } from '@server/models/actor/actor'
|
||||
import { MActorFull } from '@server/types/models'
|
||||
import { WebFingerData } from '@shared/models'
|
||||
|
||||
const webfinger = new WebFinger({
|
||||
webfist_fallback: false,
|
@ -1,7 +1,7 @@
|
||||
import { getAPId } from '@server/helpers/activitypub'
|
||||
import { retryTransactionWrapper } from '@server/helpers/database-utils'
|
||||
import { fetchVideoByUrl, VideoFetchByUrlType } from '@server/helpers/video'
|
||||
import { JobQueue } from '@server/lib/job-queue'
|
||||
import { fetchVideoByUrl, VideoFetchByUrlType } from '@server/lib/model-loaders'
|
||||
import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnail } from '@server/types/models'
|
||||
import { refreshVideoIfNeeded } from './refresh'
|
||||
import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared'
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
||||
import { PeerTubeRequestError } from '@server/helpers/requests'
|
||||
import { VideoFetchByUrlType } from '@server/helpers/video'
|
||||
import { ActorFollowScoreCache } from '@server/lib/files-cache'
|
||||
import { VideoFetchByUrlType } from '@server/lib/model-loaders'
|
||||
import { VideoModel } from '@server/models/video/video'
|
||||
import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
@ -4,13 +4,12 @@ import { ActivitypubFollowPayload } from '@shared/models'
|
||||
import { sanitizeHost } from '../../../helpers/core-utils'
|
||||
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger'
|
||||
import { REMOTE_SCHEME, WEBSERVER } from '../../../initializers/constants'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { ActorModel } from '../../../models/actor/actor'
|
||||
import { ActorFollowModel } from '../../../models/actor/actor-follow'
|
||||
import { MActor, MActorFollowActors, MActorFull } from '../../../types/models'
|
||||
import { getOrCreateAPActor } from '../../activitypub/actors'
|
||||
import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activitypub/actors'
|
||||
import { sendFollow } from '../../activitypub/send'
|
||||
import { Notifier } from '../../notifier'
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import * as Bull from 'bull'
|
||||
import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists'
|
||||
import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos'
|
||||
import { fetchVideoByUrl } from '@server/lib/model-loaders'
|
||||
import { RefreshPayload } from '@shared/models'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { fetchVideoByUrl } from '../../../helpers/video'
|
||||
import { ActorModel } from '../../../models/actor/actor'
|
||||
import { VideoPlaylistModel } from '../../../models/video/video-playlist'
|
||||
import { refreshActorIfNeeded } from '../../activitypub/actors'
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
import { ActorModel } from '../models/actor/actor'
|
||||
import { MActorAccountChannelId, MActorFull } from '../types/models'
|
||||
import { ActorModel } from '../../models/actor/actor'
|
||||
import { MActorAccountChannelId, MActorFull } from '../../types/models'
|
||||
|
||||
type ActorFetchByUrlType = 'all' | 'association-ids'
|
||||
|
2
server/lib/model-loaders/index.ts
Normal file
2
server/lib/model-loaders/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './actor'
|
||||
export * from './video'
|
64
server/lib/model-loaders/video.ts
Normal file
64
server/lib/model-loaders/video.ts
Normal file
@ -0,0 +1,64 @@
|
||||
import { VideoModel } from '@server/models/video/video'
|
||||
import {
|
||||
MVideoAccountLightBlacklistAllFiles,
|
||||
MVideoFullLight,
|
||||
MVideoIdThumbnail,
|
||||
MVideoImmutable,
|
||||
MVideoThumbnail,
|
||||
MVideoWithRights
|
||||
} from '@server/types/models'
|
||||
|
||||
type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes'
|
||||
|
||||
function fetchVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight>
|
||||
function fetchVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable>
|
||||
function fetchVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail>
|
||||
function fetchVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise<MVideoWithRights>
|
||||
function fetchVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoIdThumbnail>
|
||||
function fetchVideo (
|
||||
id: number | string,
|
||||
fetchType: VideoFetchType,
|
||||
userId?: number
|
||||
): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable>
|
||||
function fetchVideo (
|
||||
id: number | string,
|
||||
fetchType: VideoFetchType,
|
||||
userId?: number
|
||||
): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> {
|
||||
if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId)
|
||||
|
||||
if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id)
|
||||
|
||||
if (fetchType === 'only-video-with-rights') return VideoModel.loadWithRights(id)
|
||||
|
||||
if (fetchType === 'only-video') return VideoModel.load(id)
|
||||
|
||||
if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id)
|
||||
}
|
||||
|
||||
type VideoFetchByUrlType = 'all' | 'only-video' | 'only-immutable-attributes'
|
||||
|
||||
function fetchVideoByUrl (url: string, fetchType: 'all'): Promise<MVideoAccountLightBlacklistAllFiles>
|
||||
function fetchVideoByUrl (url: string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable>
|
||||
function fetchVideoByUrl (url: string, fetchType: 'only-video'): Promise<MVideoThumbnail>
|
||||
function fetchVideoByUrl (
|
||||
url: string,
|
||||
fetchType: VideoFetchByUrlType
|
||||
): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable>
|
||||
function fetchVideoByUrl (
|
||||
url: string,
|
||||
fetchType: VideoFetchByUrlType
|
||||
): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> {
|
||||
if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url)
|
||||
|
||||
if (fetchType === 'only-immutable-attributes') return VideoModel.loadByUrlImmutableAttributes(url)
|
||||
|
||||
if (fetchType === 'only-video') return VideoModel.loadByUrl(url)
|
||||
}
|
||||
|
||||
export {
|
||||
VideoFetchType,
|
||||
VideoFetchByUrlType,
|
||||
fetchVideo,
|
||||
fetchVideoByUrl
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '@server/helpers/signup'
|
||||
import { getServerCommit } from '@server/helpers/utils'
|
||||
import { CONFIG, isEmailEnabled } from '@server/initializers/config'
|
||||
import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '@server/initializers/constants'
|
||||
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '@server/lib/signup'
|
||||
import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
|
||||
import { HTMLServerConfig, RegisteredExternalAuthConfig, RegisteredIdAndPassAuthConfig, ServerConfig } from '@shared/models'
|
||||
import { Hooks } from './plugins/hooks'
|
||||
|
@ -1,13 +1,12 @@
|
||||
import { NextFunction, Request, Response } from 'express'
|
||||
import { getAPId } from '@server/helpers/activitypub'
|
||||
import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor'
|
||||
import { ActivityDelete, ActivityPubSignature } from '../../shared'
|
||||
import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
|
||||
import { logger } from '../helpers/logger'
|
||||
import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto'
|
||||
import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants'
|
||||
import { getOrCreateAPActor } from '../lib/activitypub/actors'
|
||||
import { loadActorUrlOrGetFromWebfinger } from '../helpers/webfinger'
|
||||
import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor'
|
||||
import { getAPId } from '@server/helpers/activitypub'
|
||||
import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
|
||||
import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../lib/activitypub/actors'
|
||||
|
||||
async function checkSignature (req: Request, res: Response, next: NextFunction) {
|
||||
try {
|
||||
|
@ -13,13 +13,11 @@ import {
|
||||
isAbuseVideoIsValid
|
||||
} from '@server/helpers/custom-validators/abuses'
|
||||
import { exists, isIdOrUUIDValid, isIdValid, toIntOrNull } from '@server/helpers/custom-validators/misc'
|
||||
import { doesCommentIdExist } from '@server/helpers/custom-validators/video-comments'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { doesAbuseExist, doesAccountIdExist, doesVideoExist } from '@server/helpers/middlewares'
|
||||
import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
|
||||
import { AbuseCreate, UserRight } from '@shared/models'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdExist, doesVideoExist } from './shared'
|
||||
|
||||
const abuseReportValidator = [
|
||||
body('account.id')
|
||||
|
@ -2,8 +2,7 @@ import * as express from 'express'
|
||||
import { param } from 'express-validator'
|
||||
import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { doesAccountNameWithHostExist, doesLocalAccountNameExist } from '../../helpers/middlewares'
|
||||
import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared'
|
||||
|
||||
const localAccountValidator = [
|
||||
param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as express from 'express'
|
||||
import { query } from 'express-validator'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { PAGINATION } from '@server/initializers/constants'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors } from '../shared'
|
||||
|
||||
const apPaginationValidator = [
|
||||
query('page')
|
||||
|
@ -1,12 +1,13 @@
|
||||
import * as express from 'express'
|
||||
import { body } from 'express-validator'
|
||||
import {
|
||||
isSignatureCreatorValid, isSignatureTypeValid,
|
||||
isSignatureCreatorValid,
|
||||
isSignatureTypeValid,
|
||||
isSignatureValueValid
|
||||
} from '../../../helpers/custom-validators/activitypub/signature'
|
||||
import { isDateValid } from '../../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { areValidationErrors } from '../shared'
|
||||
|
||||
const signatureValidator = [
|
||||
body('signature.type')
|
||||
|
@ -4,7 +4,7 @@ import { isActorImageFile } from '@server/helpers/custom-validators/actor-images
|
||||
import { cleanUpReqFiles } from '../../helpers/express-utils'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const updateActorImageValidatorFactory = (fieldname: string) => ([
|
||||
body(fieldname).custom((value, { req }) => isActorImageFile(req.files, fieldname)).withMessage(
|
||||
|
@ -1,15 +1,14 @@
|
||||
import { body, param } from 'express-validator'
|
||||
import * as express from 'express'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { AccountBlocklistModel } from '../../models/account/account-blocklist'
|
||||
import { isHostValid } from '../../helpers/custom-validators/servers'
|
||||
import { ServerBlocklistModel } from '../../models/server/server-blocklist'
|
||||
import { ServerModel } from '../../models/server/server'
|
||||
import { WEBSERVER } from '../../initializers/constants'
|
||||
import { doesAccountNameWithHostExist } from '../../helpers/middlewares'
|
||||
import { body, param } from 'express-validator'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { isHostValid } from '../../helpers/custom-validators/servers'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { WEBSERVER } from '../../initializers/constants'
|
||||
import { AccountBlocklistModel } from '../../models/account/account-blocklist'
|
||||
import { ServerModel } from '../../models/server/server'
|
||||
import { ServerBlocklistModel } from '../../models/server/server-blocklist'
|
||||
import { areValidationErrors, doesAccountNameWithHostExist } from './shared'
|
||||
|
||||
const blockAccountValidator = [
|
||||
body('accountName').exists().withMessage('Should have an account name with host'),
|
||||
|
@ -1,12 +1,11 @@
|
||||
import * as express from 'express'
|
||||
import { body } from 'express-validator'
|
||||
import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk'
|
||||
import { doesAccountNameWithHostExist } from '@server/helpers/middlewares'
|
||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||
import { UserRight } from '@shared/models'
|
||||
import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||
import { areValidationErrors, doesAccountNameWithHostExist } from './shared'
|
||||
|
||||
const bulkRemoveCommentsOfValidator = [
|
||||
body('accountName').exists().withMessage('Should have an account name with host'),
|
||||
|
@ -7,7 +7,7 @@ import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
|
||||
import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { isThemeRegistered } from '../../lib/plugins/theme-utils'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const customConfigUpdateValidator = [
|
||||
body('instance.name').exists().withMessage('Should have a valid instance name'),
|
||||
|
@ -1,18 +1,18 @@
|
||||
import * as express from 'express'
|
||||
import { param, query } from 'express-validator'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
|
||||
import { exists, isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import {
|
||||
areValidationErrors,
|
||||
doesAccountIdExist,
|
||||
doesAccountNameWithHostExist,
|
||||
doesUserFeedTokenCorrespond,
|
||||
doesVideoChannelIdExist,
|
||||
doesVideoChannelNameWithHostExist
|
||||
} from '../../helpers/middlewares'
|
||||
import { doesVideoExist } from '../../helpers/middlewares/videos'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
doesVideoChannelNameWithHostExist,
|
||||
doesVideoExist
|
||||
} from './shared'
|
||||
|
||||
const feedsFormatValidator = [
|
||||
param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
|
||||
|
@ -1,6 +1,7 @@
|
||||
import * as express from 'express'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { isFollowStateValid } from '@server/helpers/custom-validators/follows'
|
||||
import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { MActorFollowActorsDefault } from '@server/types/models'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
@ -8,11 +9,10 @@ import { isTestInstance } from '../../helpers/core-utils'
|
||||
import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
|
||||
import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger'
|
||||
import { SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants'
|
||||
import { ActorModel } from '../../models/actor/actor'
|
||||
import { ActorFollowModel } from '../../models/actor/actor-follow'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const listFollowsValidator = [
|
||||
query('state')
|
||||
|
@ -2,7 +2,7 @@ import * as express from 'express'
|
||||
import { param, query } from 'express-validator'
|
||||
import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs'
|
||||
import { logger, loggerTagsFactory } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const lTags = loggerTagsFactory('validators', 'jobs')
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
import * as express from 'express'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isDateValid } from '../../helpers/custom-validators/misc'
|
||||
import { query } from 'express-validator'
|
||||
import { isValidLogLevel } from '../../helpers/custom-validators/logs'
|
||||
import { isDateValid } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const getLogsValidator = [
|
||||
query('startDate')
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as express from 'express'
|
||||
import { query } from 'express-validator'
|
||||
import { join } from 'path'
|
||||
import { fetchVideo } from '@server/helpers/video'
|
||||
import { fetchVideo } from '@server/lib/model-loaders'
|
||||
import { VideoPlaylistModel } from '@server/models/video/video-playlist'
|
||||
import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
@ -9,7 +9,7 @@ import { isTestInstance } from '../../helpers/core-utils'
|
||||
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { WEBSERVER } from '../../initializers/constants'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const playlistPaths = [
|
||||
join('videos', 'watch', 'playlist'),
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as express from 'express'
|
||||
import { query } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { PAGINATION } from '@server/initializers/constants'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const paginationValidator = paginationValidatorBuilder()
|
||||
|
||||
|
@ -9,7 +9,7 @@ import { logger } from '../../helpers/logger'
|
||||
import { CONFIG } from '../../initializers/config'
|
||||
import { PluginManager } from '../../lib/plugins/plugin-manager'
|
||||
import { PluginModel } from '../../models/server/plugin'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const getPluginValidator = (pluginType: PluginType, withVersion = true) => {
|
||||
const validators: (ValidationChain | express.Handler)[] = [
|
||||
|
@ -1,14 +1,13 @@
|
||||
import * as express from 'express'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { exists, isBooleanValid, isIdOrUUIDValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
|
||||
import { isHostValid } from '../../helpers/custom-validators/servers'
|
||||
import { ServerModel } from '../../models/server/server'
|
||||
import { doesVideoExist } from '../../helpers/middlewares'
|
||||
import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { exists, isBooleanValid, isIdOrUUIDValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
|
||||
import { isHostValid } from '../../helpers/custom-validators/servers'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
|
||||
import { ServerModel } from '../../models/server/server'
|
||||
import { areValidationErrors, doesVideoExist } from './shared'
|
||||
|
||||
const videoFileRedundancyGetValidator = [
|
||||
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'),
|
||||
|
@ -1,9 +1,9 @@
|
||||
import * as express from 'express'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { query } from 'express-validator'
|
||||
import { isDateValid } from '../../helpers/custom-validators/misc'
|
||||
import { isSearchTargetValid } from '@server/helpers/custom-validators/search'
|
||||
import { isDateValid } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const videosSearchValidator = [
|
||||
query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
|
||||
|
@ -1,13 +1,13 @@
|
||||
import * as express from 'express'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers'
|
||||
import { ServerModel } from '../../models/server/server'
|
||||
import { body } from 'express-validator'
|
||||
import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
|
||||
import { Redis } from '../../lib/redis'
|
||||
import { CONFIG, isEmailEnabled } from '../../initializers/config'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers'
|
||||
import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { CONFIG, isEmailEnabled } from '../../initializers/config'
|
||||
import { Redis } from '../../lib/redis'
|
||||
import { ServerModel } from '../../models/server/server'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const serverGetValidator = [
|
||||
body('host').custom(isHostValid).withMessage('Should have a valid host'),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Response } from 'express'
|
||||
import { AbuseModel } from '../../models/abuse/abuse'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { AbuseModel } from '@server/models/abuse/abuse'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
async function doesAbuseExist (abuseId: number | string, res: Response) {
|
||||
const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
|
@ -1,8 +1,8 @@
|
||||
import { Response } from 'express'
|
||||
import { AccountModel } from '@server/models/account/account'
|
||||
import { UserModel } from '@server/models/user/user'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { AccountModel } from '../../models/account/account'
|
||||
import { MAccountDefault } from '../../types/models'
|
||||
import { MAccountDefault } from '@server/types/models'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) {
|
||||
const promise = AccountModel.load(parseInt(id + '', 10))
|
@ -1,7 +1,11 @@
|
||||
export * from './abuses'
|
||||
export * from './accounts'
|
||||
export * from './utils'
|
||||
export * from './video-blacklists'
|
||||
export * from './video-captions'
|
||||
export * from './video-channels'
|
||||
export * from './video-comments'
|
||||
export * from './video-imports'
|
||||
export * from './video-ownerships'
|
||||
export * from './video-playlists'
|
||||
export * from './videos'
|
@ -1,6 +1,6 @@
|
||||
import * as express from 'express'
|
||||
import { query, validationResult } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
|
||||
function areValidationErrors (req: express.Request, res: express.Response) {
|
||||
const errors = validationResult(req)
|
@ -1,6 +1,6 @@
|
||||
import { Response } from 'express'
|
||||
import { VideoBlacklistModel } from '../../models/video/video-blacklist'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { VideoBlacklistModel } from '@server/models/video/video-blacklist'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
async function doesVideoBlacklistExist (videoId: number, res: Response) {
|
||||
const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId)
|
@ -1,7 +1,7 @@
|
||||
import { Response } from 'express'
|
||||
import { VideoCaptionModel } from '../../models/video/video-caption'
|
||||
import { VideoCaptionModel } from '@server/models/video/video-caption'
|
||||
import { MVideoId } from '@server/types/models'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) {
|
||||
const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
|
@ -1,7 +1,7 @@
|
||||
import * as express from 'express'
|
||||
import { VideoChannelModel } from '@server/models/video/video-channel'
|
||||
import { MChannelBannerAccountDefault } from '@server/types/models'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { VideoChannelModel } from '../../models/video/video-channel'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
|
||||
const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
|
73
server/middlewares/validators/shared/video-comments.ts
Normal file
73
server/middlewares/validators/shared/video-comments.ts
Normal file
@ -0,0 +1,73 @@
|
||||
import * as express from 'express'
|
||||
import { VideoCommentModel } from '@server/models/video/video-comment'
|
||||
import { MVideoId } from '@server/types/models'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) {
|
||||
const id = parseInt(idArg + '', 10)
|
||||
const videoComment = await VideoCommentModel.loadById(id)
|
||||
|
||||
if (!videoComment) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video comment thread not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (videoComment.videoId !== video.id) {
|
||||
res.fail({ message: 'Video comment is not associated to this video.' })
|
||||
return false
|
||||
}
|
||||
|
||||
if (videoComment.inReplyToCommentId !== null) {
|
||||
res.fail({ message: 'Video comment is not a thread.' })
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoCommentThread = videoComment
|
||||
return true
|
||||
}
|
||||
|
||||
async function doesVideoCommentExist (idArg: number | string, video: MVideoId, res: express.Response) {
|
||||
const id = parseInt(idArg + '', 10)
|
||||
const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id)
|
||||
|
||||
if (!videoComment) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video comment thread not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if (videoComment.videoId !== video.id) {
|
||||
res.fail({ message: 'Video comment is not associated to this video.' })
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoCommentFull = videoComment
|
||||
return true
|
||||
}
|
||||
|
||||
async function doesCommentIdExist (idArg: number | string, res: express.Response) {
|
||||
const id = parseInt(idArg + '', 10)
|
||||
const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id)
|
||||
|
||||
if (!videoComment) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video comment thread not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoCommentFull = videoComment
|
||||
return true
|
||||
}
|
||||
|
||||
export {
|
||||
doesVideoCommentThreadExist,
|
||||
doesVideoCommentExist,
|
||||
doesCommentIdExist
|
||||
}
|
22
server/middlewares/validators/shared/video-imports.ts
Normal file
22
server/middlewares/validators/shared/video-imports.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import * as express from 'express'
|
||||
import { VideoImportModel } from '@server/models/video/video-import'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
async function doesVideoImportExist (id: number, res: express.Response) {
|
||||
const videoImport = await VideoImportModel.loadAndPopulateVideo(id)
|
||||
|
||||
if (!videoImport) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video import not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoImport = videoImport
|
||||
return true
|
||||
}
|
||||
|
||||
export {
|
||||
doesVideoImportExist
|
||||
}
|
24
server/middlewares/validators/shared/video-ownerships.ts
Normal file
24
server/middlewares/validators/shared/video-ownerships.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import * as express from 'express'
|
||||
import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
async function doesChangeVideoOwnershipExist (idArg: number | string, res: express.Response) {
|
||||
const id = parseInt(idArg + '', 10)
|
||||
const videoChangeOwnership = await VideoChangeOwnershipModel.load(id)
|
||||
|
||||
if (!videoChangeOwnership) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.NOT_FOUND_404,
|
||||
message: 'Video change ownership not found'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
res.locals.videoChangeOwnership = videoChangeOwnership
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
export {
|
||||
doesChangeVideoOwnershipExist
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import * as express from 'express'
|
||||
import { VideoPlaylistModel } from '../../models/video/video-playlist'
|
||||
import { MVideoPlaylist } from '../../types/models/video/video-playlist'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { VideoPlaylistModel } from '@server/models/video/video-playlist'
|
||||
import { MVideoPlaylist } from '@server/types/models'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
export type VideoPlaylistFetchType = 'summary' | 'all'
|
||||
async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: VideoPlaylistFetchType = 'summary') {
|
@ -1,7 +1,7 @@
|
||||
import { Response } from 'express'
|
||||
import { fetchVideo, VideoFetchType } from '../video'
|
||||
import { UserRight } from '../../../shared/models/users'
|
||||
import { VideoChannelModel } from '../../models/video/video-channel'
|
||||
import { fetchVideo, VideoFetchType } from '@server/lib/model-loaders'
|
||||
import { VideoChannelModel } from '@server/models/video/video-channel'
|
||||
import { VideoFileModel } from '@server/models/video/video-file'
|
||||
import {
|
||||
MUser,
|
||||
MUserAccountId,
|
||||
@ -12,8 +12,8 @@ import {
|
||||
MVideoThumbnail,
|
||||
MVideoWithRights
|
||||
} from '@server/types/models'
|
||||
import { VideoFileModel } from '@server/models/video/video-file'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
import { UserRight } from '@shared/models'
|
||||
|
||||
async function doesVideoExist (id: number | string, res: Response, fetchType: VideoFetchType = 'all') {
|
||||
const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined
|
@ -1,5 +1,5 @@
|
||||
import { SORTABLE_COLUMNS } from '../../initializers/constants'
|
||||
import { checkSort, createSortableColumns } from './utils'
|
||||
import { checkSort, createSortableColumns } from './shared'
|
||||
|
||||
// Initialize constants here for better performances
|
||||
const SORTABLE_USERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USERS)
|
||||
|
@ -1,11 +1,11 @@
|
||||
import * as express from 'express'
|
||||
import { param } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
|
||||
import { PluginManager } from '../../lib/plugins/plugin-manager'
|
||||
import { isSafePath } from '../../helpers/custom-validators/misc'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { isSafePath } from '../../helpers/custom-validators/misc'
|
||||
import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { PluginManager } from '../../lib/plugins/plugin-manager'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const serveThemeCSSValidator = [
|
||||
param('themeName').custom(isPluginNameValid).withMessage('Should have a valid theme name'),
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as express from 'express'
|
||||
import { body, query } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { exists, isDateValid } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const userHistoryListValidator = [
|
||||
query('search')
|
||||
|
@ -1,9 +1,9 @@
|
||||
import * as express from 'express'
|
||||
import { body, query } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
|
||||
import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc'
|
||||
import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const listUserNotificationsValidator = [
|
||||
query('unread')
|
||||
|
@ -6,7 +6,7 @@ import { toArray } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { WEBSERVER } from '../../initializers/constants'
|
||||
import { ActorFollowModel } from '../../models/actor/actor-follow'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const userSubscriptionListValidator = [
|
||||
query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
|
||||
|
@ -30,13 +30,12 @@ import {
|
||||
} from '../../helpers/custom-validators/users'
|
||||
import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { doesVideoExist } from '../../helpers/middlewares'
|
||||
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
|
||||
import { isThemeRegistered } from '../../lib/plugins/theme-utils'
|
||||
import { Redis } from '../../lib/redis'
|
||||
import { UserModel } from '../../models/user/user'
|
||||
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../lib/signup'
|
||||
import { ActorModel } from '../../models/actor/actor'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { UserModel } from '../../models/user/user'
|
||||
import { areValidationErrors, doesVideoExist } from './shared'
|
||||
|
||||
const usersListValidator = [
|
||||
query('blocked')
|
||||
|
@ -1,11 +1,10 @@
|
||||
import * as express from 'express'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
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'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { areValidationErrors, doesVideoBlacklistExist, doesVideoExist } from '../shared'
|
||||
|
||||
const videosBlacklistRemoveValidator = [
|
||||
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
|
||||
|
@ -1,13 +1,12 @@
|
||||
import * as express from 'express'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
|
||||
import { body, param } from 'express-validator'
|
||||
import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants'
|
||||
import { UserRight } from '../../../../shared'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
|
||||
import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions'
|
||||
import { cleanUpReqFiles } from '../../../helpers/express-utils'
|
||||
import { checkUserCanManageVideo, doesVideoCaptionExist, doesVideoExist } from '../../../helpers/middlewares'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants'
|
||||
import { areValidationErrors, checkUserCanManageVideo, doesVideoCaptionExist, doesVideoExist } from '../shared'
|
||||
|
||||
const addVideoCaptionValidator = [
|
||||
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'),
|
||||
|
@ -12,10 +12,9 @@ import {
|
||||
isVideoChannelSupportValid
|
||||
} from '../../../helpers/custom-validators/video-channels'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares'
|
||||
import { ActorModel } from '../../../models/actor/actor'
|
||||
import { VideoChannelModel } from '../../../models/video/video-channel'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { areValidationErrors, doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../shared'
|
||||
|
||||
const videoChannelsAddValidator = [
|
||||
body('name').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'),
|
||||
|
@ -2,19 +2,14 @@ import * as express from 'express'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { MUserAccountUrl } from '@server/types/models'
|
||||
import { UserRight } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { exists, isBooleanValid, isIdOrUUIDValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import {
|
||||
doesVideoCommentExist,
|
||||
doesVideoCommentThreadExist,
|
||||
isValidVideoCommentText
|
||||
} from '../../../helpers/custom-validators/video-comments'
|
||||
import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { doesVideoExist } from '../../../helpers/middlewares'
|
||||
import { AcceptResult, isLocalVideoCommentReplyAccepted, isLocalVideoThreadAccepted } from '../../../lib/moderation'
|
||||
import { Hooks } from '../../../lib/plugins/hooks'
|
||||
import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { areValidationErrors, doesVideoCommentExist, doesVideoCommentThreadExist, doesVideoExist } from '../shared'
|
||||
|
||||
const listVideoCommentsValidator = [
|
||||
query('isLocal')
|
||||
|
@ -2,18 +2,17 @@ import * as express from 'express'
|
||||
import { body } from 'express-validator'
|
||||
import { isPreImportVideoAccepted } from '@server/lib/moderation'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||
import { VideoImportCreate } from '@shared/models/videos/import/video-import-create.model'
|
||||
import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports'
|
||||
import { isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos'
|
||||
import { cleanUpReqFiles } from '../../../helpers/express-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { doesVideoChannelOfAccountExist } from '../../../helpers/middlewares'
|
||||
import { CONFIG } from '../../../initializers/config'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { areValidationErrors, doesVideoChannelOfAccountExist } from '../shared'
|
||||
import { getCommonVideoEditAttributes } from './videos'
|
||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const videoImportAddValidator = getCommonVideoEditAttributes().concat([
|
||||
body('channelId')
|
||||
|
@ -1,20 +1,19 @@
|
||||
import * as express from 'express'
|
||||
import { body, param } from 'express-validator'
|
||||
import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '@server/helpers/middlewares/videos'
|
||||
import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
|
||||
import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { VideoModel } from '@server/models/video/video'
|
||||
import { VideoLiveModel } from '@server/models/video/video-live'
|
||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||
import { ServerErrorCode, UserRight, VideoState } from '@shared/models'
|
||||
import { isBooleanValid, isIdOrUUIDValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import { isVideoNameValid } from '../../../helpers/custom-validators/videos'
|
||||
import { cleanUpReqFiles } from '../../../helpers/express-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { CONFIG } from '../../../initializers/config'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { areValidationErrors, checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../shared'
|
||||
import { getCommonVideoEditAttributes } from './videos'
|
||||
import { VideoModel } from '@server/models/video/video'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
|
||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||
import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
|
||||
|
||||
const videoLiveGetValidator = [
|
||||
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
|
||||
|
@ -25,12 +25,11 @@ import {
|
||||
import { isVideoImage } from '../../../helpers/custom-validators/videos'
|
||||
import { cleanUpReqFiles } from '../../../helpers/express-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { doesVideoChannelIdExist, doesVideoExist, doesVideoPlaylistExist, VideoPlaylistFetchType } from '../../../helpers/middlewares'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
|
||||
import { VideoPlaylistElementModel } from '../../../models/video/video-playlist-element'
|
||||
import { MVideoPlaylist } from '../../../types/models/video/video-playlist'
|
||||
import { authenticatePromiseIfNeeded } from '../../auth'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { areValidationErrors, doesVideoChannelIdExist, doesVideoExist, doesVideoPlaylistExist, VideoPlaylistFetchType } from '../shared'
|
||||
|
||||
const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([
|
||||
body('displayName')
|
||||
|
@ -1,15 +1,14 @@
|
||||
import * as express from 'express'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { VideoRateType } from '../../../../shared/models/videos'
|
||||
import { isAccountNameValid } from '../../../helpers/custom-validators/accounts'
|
||||
import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
|
||||
import { isRatingValid } from '../../../helpers/custom-validators/video-rates'
|
||||
import { isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
|
||||
import { VideoRateType } from '../../../../shared/models/videos'
|
||||
import { isAccountNameValid } from '../../../helpers/custom-validators/accounts'
|
||||
import { doesVideoExist } from '../../../helpers/middlewares'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { areValidationErrors, doesVideoExist } from '../shared'
|
||||
|
||||
const videoUpdateRateValidator = [
|
||||
param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
|
||||
|
@ -1,11 +1,10 @@
|
||||
import * as express from 'express'
|
||||
import { param } from 'express-validator'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { VideoShareModel } from '../../../models/video/video-share'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { doesVideoExist } from '../../../helpers/middlewares'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { areValidationErrors, doesVideoExist } from '../shared'
|
||||
|
||||
const videosShareValidator = [
|
||||
param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
|
||||
|
@ -1,10 +1,9 @@
|
||||
import { body, param } from 'express-validator'
|
||||
import * as express from 'express'
|
||||
import { isIdOrUUIDValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { doesVideoExist } from '../../../helpers/middlewares'
|
||||
import { body, param } from 'express-validator'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { isIdOrUUIDValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors, doesVideoExist } from '../shared'
|
||||
|
||||
const videoWatchingValidator = [
|
||||
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
toValueOrNull
|
||||
} from '../../../helpers/custom-validators/misc'
|
||||
import { isBooleanBothQueryValid, isNumberArray, isStringArray } from '../../../helpers/custom-validators/search'
|
||||
import { checkUserCanTerminateOwnershipChange, doesChangeVideoOwnershipExist } from '../../../helpers/custom-validators/video-ownership'
|
||||
import { checkUserCanTerminateOwnershipChange } from '../../../helpers/custom-validators/video-ownership'
|
||||
import {
|
||||
isScheduleVideoUpdatePrivacyValid,
|
||||
isVideoCategoryValid,
|
||||
@ -42,12 +42,6 @@ import {
|
||||
import { cleanUpReqFiles } from '../../../helpers/express-utils'
|
||||
import { getDurationFromVideoFile } from '../../../helpers/ffprobe-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import {
|
||||
checkUserCanManageVideo,
|
||||
doesVideoChannelOfAccountExist,
|
||||
doesVideoExist,
|
||||
doesVideoFileOfVideoExist
|
||||
} from '../../../helpers/middlewares'
|
||||
import { deleteFileAndCatch } from '../../../helpers/utils'
|
||||
import { getVideoWithAttributes } from '../../../helpers/video'
|
||||
import { CONFIG } from '../../../initializers/config'
|
||||
@ -57,7 +51,14 @@ import { Hooks } from '../../../lib/plugins/hooks'
|
||||
import { AccountModel } from '../../../models/account/account'
|
||||
import { VideoModel } from '../../../models/video/video'
|
||||
import { authenticatePromiseIfNeeded } from '../../auth'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import {
|
||||
areValidationErrors,
|
||||
checkUserCanManageVideo,
|
||||
doesChangeVideoOwnershipExist,
|
||||
doesVideoChannelOfAccountExist,
|
||||
doesVideoExist,
|
||||
doesVideoFileOfVideoExist
|
||||
} from '../shared'
|
||||
|
||||
const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([
|
||||
body('videofile')
|
||||
|
@ -5,7 +5,7 @@ import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/w
|
||||
import { getHostWithPort } from '../../helpers/express-utils'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { ActorModel } from '../../models/actor/actor'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const webfingerValidator = [
|
||||
query('resource').custom(isWebfingerLocalResourceValid).withMessage('Should have a valid webfinger resource'),
|
||||
|
Loading…
Reference in New Issue
Block a user