2021-06-02 18:15:41 +02:00
|
|
|
|
2021-07-22 11:15:17 +02:00
|
|
|
import { OutgoingHttpHeaders } from 'http'
|
2020-06-23 14:10:17 +02:00
|
|
|
import { RegisterServerAuthExternalOptions } from '@server/types'
|
|
|
|
import {
|
2020-07-24 15:05:51 +02:00
|
|
|
MAbuseMessage,
|
2020-07-28 11:12:16 +02:00
|
|
|
MAbuseReporter,
|
2020-06-23 14:10:17 +02:00
|
|
|
MAccountBlocklist,
|
2021-04-06 17:01:35 +02:00
|
|
|
MActorFollowActorsDefault,
|
2020-06-23 14:10:17 +02:00
|
|
|
MActorUrl,
|
2021-04-06 17:01:35 +02:00
|
|
|
MChannelBannerAccountDefault,
|
2022-08-10 09:53:39 +02:00
|
|
|
MChannelSyncChannel,
|
2020-06-23 14:10:17 +02:00
|
|
|
MStreamingPlaylist,
|
|
|
|
MVideoChangeOwnershipFull,
|
|
|
|
MVideoFile,
|
2021-06-11 09:57:19 +02:00
|
|
|
MVideoFormattableDetails,
|
2021-06-11 14:09:33 +02:00
|
|
|
MVideoId,
|
2020-06-23 14:10:17 +02:00
|
|
|
MVideoImmutable,
|
2021-03-03 15:22:38 +01:00
|
|
|
MVideoLive,
|
2020-06-23 14:10:17 +02:00
|
|
|
MVideoPlaylistFull,
|
2021-03-03 15:22:38 +01:00
|
|
|
MVideoPlaylistFullSummary
|
2020-06-23 14:10:17 +02:00
|
|
|
} from '@server/types/models'
|
|
|
|
import { MOAuthTokenUser } from '@server/types/models/oauth/oauth-token'
|
|
|
|
import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
|
|
|
|
import { MVideoImportDefault } from '@server/types/models/video/video-import'
|
|
|
|
import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
|
|
|
|
import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
|
2021-07-16 10:42:24 +02:00
|
|
|
import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
|
2021-05-10 11:13:41 +02:00
|
|
|
import { File as UploadXFile, Metadata } from '@uploadx/core'
|
2020-06-18 13:38:20 +02:00
|
|
|
import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
|
2019-08-15 11:53:26 +02:00
|
|
|
import {
|
|
|
|
MAccountDefault,
|
|
|
|
MActorAccountChannelId,
|
|
|
|
MActorFollowActorsDefaultSubscription,
|
|
|
|
MActorFull,
|
|
|
|
MComment,
|
|
|
|
MCommentOwnerVideoReply,
|
|
|
|
MUserDefault,
|
|
|
|
MVideoBlacklist,
|
|
|
|
MVideoCaptionVideo,
|
|
|
|
MVideoFullLight,
|
|
|
|
MVideoRedundancyVideo,
|
|
|
|
MVideoShareActor,
|
2021-06-11 14:26:37 +02:00
|
|
|
MVideoThumbnail
|
2022-02-11 10:51:33 +01:00
|
|
|
} from './models'
|
2021-07-22 11:15:17 +02:00
|
|
|
import { Writable } from 'stream'
|
2022-06-21 15:31:25 +02:00
|
|
|
import { MVideoSource } from './models/video/video-source'
|
2021-06-02 18:15:41 +02:00
|
|
|
|
2019-03-19 10:35:15 +01:00
|
|
|
declare module 'express' {
|
2020-06-18 10:45:25 +02:00
|
|
|
export interface Request {
|
2020-06-17 10:55:40 +02:00
|
|
|
query: any
|
2021-05-10 11:13:41 +02:00
|
|
|
method: HttpMethod
|
2020-06-17 10:55:40 +02:00
|
|
|
}
|
2021-05-10 11:13:41 +02:00
|
|
|
|
|
|
|
// Upload using multer or uploadx middleware
|
|
|
|
export type MulterOrUploadXFile = UploadXFile | Express.Multer.File
|
|
|
|
|
|
|
|
export type UploadFiles = {
|
|
|
|
[fieldname: string]: MulterOrUploadXFile[]
|
|
|
|
} | MulterOrUploadXFile[]
|
|
|
|
|
|
|
|
// Partial object used by some functions to check the file mimetype/extension
|
|
|
|
export type UploadFileForCheck = {
|
|
|
|
originalname: string
|
|
|
|
mimetype: string
|
2022-02-11 10:51:33 +01:00
|
|
|
size: number
|
2021-03-03 15:22:38 +01:00
|
|
|
}
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
export type UploadFilesForCheck = {
|
|
|
|
[fieldname: string]: UploadFileForCheck[]
|
|
|
|
} | UploadFileForCheck[]
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
// Upload file with a duration added by our middleware
|
2022-06-21 15:31:25 +02:00
|
|
|
export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size', 'originalname'> & {
|
2021-05-10 11:13:41 +02:00
|
|
|
duration: number
|
|
|
|
}
|
2020-09-17 09:20:52 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
// Extends Metadata property of UploadX object
|
|
|
|
export type UploadXFileMetadata = Metadata & VideoCreate & {
|
|
|
|
previewfile: Express.Multer.File[]
|
|
|
|
thumbnailfile: Express.Multer.File[]
|
|
|
|
}
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
// Our custom UploadXFile object using our custom metadata
|
|
|
|
export type CustomUploadXFile <T extends Metadata> = UploadXFile & { metadata: T }
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
export type EnhancedUploadXFile = CustomUploadXFile<UploadXFileMetadata> & {
|
|
|
|
duration: number
|
|
|
|
path: string
|
|
|
|
filename: string
|
2022-06-21 15:31:25 +02:00
|
|
|
originalname: string
|
2021-05-10 11:13:41 +02:00
|
|
|
}
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2021-06-01 01:36:53 +02:00
|
|
|
// Extends Response with added functions and potential variables passed by middlewares
|
2021-05-10 11:13:41 +02:00
|
|
|
interface Response {
|
2021-06-01 01:36:53 +02:00
|
|
|
fail: (options: {
|
|
|
|
message: string
|
2021-06-02 18:15:41 +02:00
|
|
|
|
|
|
|
title?: string
|
|
|
|
status?: number
|
2022-10-19 10:43:53 +02:00
|
|
|
type?: ServerErrorCode | string
|
2021-06-02 18:15:41 +02:00
|
|
|
instance?: string
|
|
|
|
|
|
|
|
data?: PeerTubeProblemDocumentData
|
|
|
|
}) => void
|
2021-06-01 01:36:53 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
locals: {
|
2022-07-05 15:43:21 +02:00
|
|
|
requestStart: number
|
|
|
|
|
2021-07-22 11:15:17 +02:00
|
|
|
apicache: {
|
|
|
|
content: string | Buffer
|
|
|
|
write: Writable['write']
|
|
|
|
writeHead: Response['writeHead']
|
|
|
|
end: Response['end']
|
|
|
|
cacheable: boolean
|
|
|
|
headers: OutgoingHttpHeaders
|
|
|
|
}
|
|
|
|
|
2021-06-02 18:15:41 +02:00
|
|
|
docUrl?: string
|
|
|
|
|
2021-06-11 09:57:19 +02:00
|
|
|
videoAPI?: MVideoFormattableDetails
|
2021-05-10 11:13:41 +02:00
|
|
|
videoAll?: MVideoFullLight
|
|
|
|
onlyImmutableVideo?: MVideoImmutable
|
|
|
|
onlyVideo?: MVideoThumbnail
|
2021-06-11 14:09:33 +02:00
|
|
|
videoId?: MVideoId
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoLive?: MVideoLive
|
2022-05-03 11:38:07 +02:00
|
|
|
videoLiveSession?: MVideoLiveSession
|
2019-08-15 11:53:26 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoShare?: MVideoShareActor
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2022-06-21 15:31:25 +02:00
|
|
|
videoSource?: MVideoSource
|
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoFile?: MVideoFile
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoFileResumable?: EnhancedUploadXFile
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoImport?: MVideoImportDefault
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoBlacklist?: MVideoBlacklist
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoCaption?: MVideoCaptionVideo
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
abuse?: MAbuseReporter
|
|
|
|
abuseMessage?: MAbuseMessage
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoStreamingPlaylist?: MStreamingPlaylist
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoChannel?: MChannelBannerAccountDefault
|
2022-08-10 09:53:39 +02:00
|
|
|
videoChannelSync?: MChannelSyncChannel
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoPlaylistFull?: MVideoPlaylistFull
|
|
|
|
videoPlaylistSummary?: MVideoPlaylistFullSummary
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoPlaylistElement?: MVideoPlaylistElement
|
|
|
|
videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
accountVideoRate?: MAccountVideoRateAccountVideo
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
videoCommentFull?: MCommentOwnerVideoReply
|
|
|
|
videoCommentThread?: MComment
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
follow?: MActorFollowActorsDefault
|
|
|
|
subscription?: MActorFollowActorsDefaultSubscription
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
nextOwner?: MAccountDefault
|
|
|
|
videoChangeOwnership?: MVideoChangeOwnershipFull
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
account?: MAccountDefault
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
actorUrl?: MActorUrl
|
|
|
|
actorFull?: MActorFull
|
|
|
|
|
|
|
|
user?: MUserDefault
|
|
|
|
|
|
|
|
server?: MServer
|
|
|
|
|
|
|
|
videoRedundancy?: MVideoRedundancyVideo
|
2019-03-19 10:35:15 +01:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
accountBlock?: MAccountBlocklist
|
|
|
|
serverBlock?: MServerBlocklist
|
2019-07-05 13:54:32 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
oauth?: {
|
|
|
|
token: MOAuthTokenUser
|
|
|
|
}
|
2019-07-10 16:59:53 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
signature?: {
|
|
|
|
actor: MActorAccountChannelId
|
|
|
|
}
|
2020-04-28 14:49:03 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
authenticated?: boolean
|
|
|
|
|
|
|
|
registeredPlugin?: RegisteredPlugin
|
|
|
|
|
|
|
|
externalAuth?: RegisterServerAuthExternalOptions
|
|
|
|
|
|
|
|
plugin?: MPlugin
|
2022-03-24 13:36:47 +01:00
|
|
|
|
|
|
|
localViewerFull?: MLocalVideoViewerWithWatchSections
|
2022-08-10 09:53:39 +02:00
|
|
|
|
2021-05-10 11:13:41 +02:00
|
|
|
}
|
|
|
|
}
|
2019-03-19 10:35:15 +01:00
|
|
|
}
|