1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00

Better thumbnail error handling

* Had to upgrade to es2022 to use `cause` error
 * Had to declare class attributes with declare for sequelize models, so
   it still works as before
This commit is contained in:
Chocobozzz 2025-07-25 17:01:36 +02:00
parent 29a88c0dde
commit 13bceb5f40
No known key found for this signature in database
GPG key ID: 583A612D890159BE
77 changed files with 919 additions and 912 deletions

View file

@ -1,11 +1,11 @@
import { NgIf } from '@angular/common'
import { CommonModule } from '@angular/common'
import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, inject, input, output, viewChild } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { ActivatedRoute, Router } from '@angular/router'
import { ActivatedRoute } from '@angular/router'
import { VideoEdit } from '@app/+videos-publish-manage/shared-manage/common/video-edit.model'
import { VideoUploadService } from '@app/+videos-publish-manage/shared-manage/common/video-upload.service'
import { VideoManageController } from '@app/+videos-publish-manage/shared-manage/video-manage-controller.service'
import { CanComponentDeactivate, CanDeactivateGuard, HooksService, MetaService, Notifier, ServerService } from '@app/core'
import { CanComponentDeactivate, HooksService, MetaService, Notifier, ServerService } from '@app/core'
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
import { UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'
import debug from 'debug'
@ -29,7 +29,7 @@ const debugLogger = debug('peertube:video-publish')
'./video-upload.component.scss'
],
imports: [
NgIf,
CommonModule,
DragDropDirective,
GlobalIconComponent,
NgbTooltip,
@ -49,8 +49,6 @@ export class VideoUploadComponent implements OnInit, OnDestroy, AfterViewInit, C
private route = inject(ActivatedRoute)
private videoUploadService = inject(VideoUploadService)
private manageController = inject(VideoManageController)
private router = inject(Router)
private canDeactivateGuard = inject(CanDeactivateGuard)
readonly userChannels = input.required<SelectChannelItem[]>()
readonly userQuota = input.required<UserVideoQuota>()
@ -167,6 +165,7 @@ export class VideoUploadComponent implements OnInit, OnDestroy, AfterViewInit, C
this.firstStep = true
this.videoEdit = undefined
this.uploadingAudioFile = false
this.audioPreviewFile = undefined
}
uploadAudio () {

View file

@ -29,7 +29,11 @@ export function getUploadXRetryConfig () {
}
export function buildHTTPErrorResponse (state: UploadState): HttpErrorResponse {
const error = state.response?.error?.message || state.response?.error || 'Unknown error'
const response = state.response
console.log(response)
const error = response?.detail || $localize`Unknown error`
return {
error: new Error(error),

View file

@ -1,3 +1,4 @@
export * from './file-storage.enum.js'
export * from './peertube-error.model.js'
export * from './result-list.model.js'
export * from './simple-logger.model.js'

View file

@ -0,0 +1,26 @@
import { OAuth2ErrorCodeType, ServerErrorCodeType } from '../server/server-error-code.enum.js'
export type InternalErrorCodeType = 'INVALID_IMAGE_FILE'
type ErrorCode = ServerErrorCodeType | OAuth2ErrorCodeType | InternalErrorCodeType
export class PeerTubeError extends Error {
code: ErrorCode
isPeerTubeError = true
constructor (message: string, code: ErrorCode, cause?: Error) {
super(message, { cause })
this.code = code
}
static fromError (error: Error, code: ErrorCode) {
return new PeerTubeError(error.message, code, error)
}
}
export function isPeerTubeError (error: any): error is PeerTubeError {
if (!error) return false
return error instanceof PeerTubeError || error.isPeerTubeError === true
}

View file

@ -1,19 +1,20 @@
import express from 'express'
import { move } from 'fs-extra/esm'
import { readFile } from 'fs/promises'
import { decode } from 'magnet-uri'
import parseTorrent, { Instance } from 'parse-torrent'
import { join } from 'path'
import { buildVideoFromImport, buildYoutubeDLImport, insertFromImportIntoDB, YoutubeDlImportError } from '@server/lib/video-pre-import.js'
import { MThumbnail, MVideoThumbnail } from '@server/types/models/index.js'
import {
HttpStatusCode,
HttpStatusCodeType,
ServerErrorCode,
ThumbnailType,
VideoImportCreate,
VideoImportPayload,
VideoImportState
} from '@peertube/peertube-models'
import { buildVideoFromImport, buildYoutubeDLImport, insertFromImportIntoDB, YoutubeDlImportError } from '@server/lib/video-pre-import.js'
import { MThumbnail, MVideoThumbnail } from '@server/types/models/index.js'
import express from 'express'
import { move } from 'fs-extra/esm'
import { readFile } from 'fs/promises'
import { decode } from 'magnet-uri'
import parseTorrent, { Instance } from 'parse-torrent'
import { join } from 'path'
import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger.js'
import { isArray } from '../../../helpers/custom-validators/misc.js'
import { cleanUpReqFiles, createReqFiles } from '../../../helpers/express-utils.js'
@ -40,20 +41,23 @@ const reqVideoFileImport = createReqFiles(
{ ...MIMETYPES.TORRENT.MIMETYPE_EXT, ...MIMETYPES.IMAGE.MIMETYPE_EXT }
)
videoImportsRouter.post('/imports',
videoImportsRouter.post(
'/imports',
authenticate,
reqVideoFileImport,
asyncMiddleware(videoImportAddValidator),
asyncRetryTransactionMiddleware(handleVideoImport)
)
videoImportsRouter.post('/imports/:id/cancel',
videoImportsRouter.post(
'/imports/:id/cancel',
authenticate,
asyncMiddleware(videoImportCancelValidator),
asyncRetryTransactionMiddleware(cancelVideoImport)
)
videoImportsRouter.delete('/imports/:id',
videoImportsRouter.delete(
'/imports/:id',
authenticate,
asyncMiddleware(videoImportDeleteValidator),
asyncRetryTransactionMiddleware(deleteVideoImport)
@ -152,7 +156,7 @@ async function handleTorrentImport (req: express.Request, res: express.Response,
return res.json(videoImport.toFormattedJSON()).end()
}
function statusFromYtDlImportError (err: YoutubeDlImportError): number {
function statusFromYtDlImportError (err: YoutubeDlImportError): HttpStatusCodeType {
switch (err.code) {
case YoutubeDlImportError.CODE.NOT_ONLY_UNICAST_URL:
return HttpStatusCode.FORBIDDEN_403

View file

@ -1,5 +1,5 @@
import { ffprobePromise, getChaptersFromContainer } from '@peertube/peertube-ffmpeg'
import { ThumbnailType, VideoCreate } from '@peertube/peertube-models'
import { isPeerTubeError, ThumbnailType, VideoCreate } from '@peertube/peertube-models'
import { uuidToShort } from '@peertube/peertube-node-utils'
import { getResumableUploadPath } from '@server/helpers/upload.js'
import { LocalVideoCreator } from '@server/lib/local-video-creator.js'
@ -38,7 +38,8 @@ const reqVideoFileAddResumable = createReqFiles(
getResumableUploadPath()
)
uploadRouter.post('/upload',
uploadRouter.post(
'/upload',
openapiOperationDoc({ operationId: 'uploadLegacy' }),
authenticate,
setReqTimeout(1000 * 60 * 10), // Uploading the video could be long
@ -90,11 +91,14 @@ async function addVideoResumable (req: express.Request, res: express.Response) {
const videoInfo = videoPhysicalFile.metadata
const files = { previewfile: videoInfo.previewfile, thumbnailfile: videoInfo.thumbnailfile }
try {
const response = await addVideo({ req, res, videoPhysicalFile, videoInfo, files })
await Redis.Instance.deleteUploadSession(req.query.upload_id)
await uploadx.storage.delete(res.locals.uploadVideoFileResumable)
return res.json(response)
} finally {
await Redis.Instance.deleteUploadSession(req.query.upload_id)
await uploadx.storage.delete(res.locals.uploadVideoFileResumable)
}
}
async function addVideo (options: {
@ -157,6 +161,7 @@ async function addVideo (options: {
thumbnails
})
try {
const { video } = await localVideoCreator.create()
auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(video.toFormattedDetailsJSON()))
@ -171,6 +176,17 @@ async function addVideo (options: {
uuid: video.uuid
}
}
} catch (err) {
if (isPeerTubeError(err) && err.code === 'INVALID_IMAGE_FILE') {
logger.warn('Invalid thumbnail file provided for video upload.', { err, ...lTags() })
return res.fail({
message: req.t('The provided thumbnail file is invalid.')
})
}
throw err
}
}
async function deleteUploadResumableCache (req: express.Request, res: express.Response, next: express.NextFunction) {

View file

@ -3,6 +3,7 @@ import {
LiveVideoCreate,
LiveVideoLatencyMode,
NSFWFlag,
PeerTubeError,
ThumbnailType,
ThumbnailType_Type,
VideoCreate,
@ -258,6 +259,9 @@ export class LocalVideoCreator {
type,
automaticallyGenerated: thumbnail.automaticallyGenerated || false,
keepOriginal: thumbnail.keepOriginal
}).catch(err => {
// eslint-disable-next-line @typescript-eslint/only-throw-error
throw PeerTubeError.fromError(err, 'INVALID_IMAGE_FILE')
})
)

View file

@ -19,25 +19,24 @@ import { AbuseModel } from './abuse.js'
]
})
export class AbuseMessageModel extends SequelizeModel<AbuseMessageModel> {
@AllowNull(false)
@Is('AbuseMessage', value => throwIfNotValid(value, isAbuseMessageValid, 'message'))
@Column(DataType.TEXT)
message: string
declare message: string
@AllowNull(false)
@Column
byModerator: boolean
declare byModerator: boolean
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => AccountModel)
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -46,11 +45,11 @@ export class AbuseMessageModel extends SequelizeModel<AbuseMessageModel> {
},
onDelete: 'set null'
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
@ForeignKey(() => AbuseModel)
@Column
abuseId: number
declare abuseId: number
@BelongsTo(() => AbuseModel, {
foreignKey: {
@ -59,7 +58,7 @@ export class AbuseMessageModel extends SequelizeModel<AbuseMessageModel> {
},
onDelete: 'cascade'
})
Abuse: Awaited<AbuseModel>
declare Abuse: Awaited<AbuseModel>
static listForApi (abuseId: number) {
const getQuery = (forCount: boolean) => {

View file

@ -200,38 +200,38 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
@Default(null)
@Is('AbuseReason', value => throwIfNotValid(value, isAbuseReasonValid, 'reason'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ABUSES.REASON.max))
reason: string
declare reason: string
@AllowNull(false)
@Default(null)
@Is('AbuseState', value => throwIfNotValid(value, isAbuseStateValid, 'state'))
@Column
state: AbuseStateType
declare state: AbuseStateType
@AllowNull(true)
@Default(null)
@Is('AbuseModerationComment', value => throwIfNotValid(value, isAbuseModerationCommentValid, 'moderationComment', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ABUSES.MODERATION_COMMENT.max))
moderationComment: string
declare moderationComment: string
@AllowNull(true)
@Default(null)
@Column(DataType.ARRAY(DataType.INTEGER))
predefinedReasons: AbusePredefinedReasonsType[]
declare predefinedReasons: AbusePredefinedReasonsType[]
@AllowNull(true)
@Column
processedAt: Date
declare processedAt: Date
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => AccountModel)
@Column
reporterAccountId: number
declare reporterAccountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -241,11 +241,11 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
as: 'ReporterAccount',
onDelete: 'set null'
})
ReporterAccount: Awaited<AccountModel>
declare ReporterAccount: Awaited<AccountModel>
@ForeignKey(() => AccountModel)
@Column
flaggedAccountId: number
declare flaggedAccountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -255,7 +255,7 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
as: 'FlaggedAccount',
onDelete: 'set null'
})
FlaggedAccount: Awaited<AccountModel>
declare FlaggedAccount: Awaited<AccountModel>
@HasOne(() => VideoCommentAbuseModel, {
foreignKey: {
@ -264,7 +264,7 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
},
onDelete: 'cascade'
})
VideoCommentAbuse: Awaited<VideoCommentAbuseModel>
declare VideoCommentAbuse: Awaited<VideoCommentAbuseModel>
@HasOne(() => VideoAbuseModel, {
foreignKey: {
@ -273,7 +273,7 @@ export class AbuseModel extends SequelizeModel<AbuseModel> {
},
onDelete: 'cascade'
})
VideoAbuse: Awaited<VideoAbuseModel>
declare VideoAbuse: Awaited<VideoAbuseModel>
static loadByIdWithReporter (id: number): Promise<MAbuseReporter> {
const query = {

View file

@ -16,31 +16,30 @@ import { SequelizeModel } from '../shared/index.js'
]
})
export class VideoAbuseModel extends SequelizeModel<VideoAbuseModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(true)
@Default(null)
@Column
startAt: number
declare startAt: number
@AllowNull(true)
@Default(null)
@Column
endAt: number
declare endAt: number
@AllowNull(true)
@Default(null)
@Column(DataType.JSONB)
deletedVideo: VideoDetails
declare deletedVideo: VideoDetails
@ForeignKey(() => AbuseModel)
@Column
abuseId: number
declare abuseId: number
@BelongsTo(() => AbuseModel, {
foreignKey: {
@ -48,11 +47,11 @@ export class VideoAbuseModel extends SequelizeModel<VideoAbuseModel> {
},
onDelete: 'cascade'
})
Abuse: Awaited<AbuseModel>
declare Abuse: Awaited<AbuseModel>
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -60,5 +59,5 @@ export class VideoAbuseModel extends SequelizeModel<VideoAbuseModel> {
},
onDelete: 'set null'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
}

View file

@ -15,16 +15,15 @@ import { SequelizeModel } from '../shared/index.js'
]
})
export class VideoCommentAbuseModel extends SequelizeModel<VideoCommentAbuseModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => AbuseModel)
@Column
abuseId: number
declare abuseId: number
@BelongsTo(() => AbuseModel, {
foreignKey: {
@ -32,11 +31,11 @@ export class VideoCommentAbuseModel extends SequelizeModel<VideoCommentAbuseMode
},
onDelete: 'cascade'
})
Abuse: Awaited<AbuseModel>
declare Abuse: Awaited<AbuseModel>
@ForeignKey(() => VideoCommentModel)
@Column
videoCommentId: number
declare videoCommentId: number
@BelongsTo(() => VideoCommentModel, {
foreignKey: {
@ -44,5 +43,5 @@ export class VideoCommentAbuseModel extends SequelizeModel<VideoCommentAbuseMode
},
onDelete: 'set null'
})
VideoComment: Awaited<VideoCommentModel>
declare VideoComment: Awaited<VideoCommentModel>
}

View file

@ -22,16 +22,15 @@ import { WEBSERVER } from '@server/initializers/constants.js'
]
})
export class AccountBlocklistModel extends SequelizeModel<AccountBlocklistModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => AccountModel)
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -41,11 +40,11 @@ export class AccountBlocklistModel extends SequelizeModel<AccountBlocklistModel>
as: 'ByAccount',
onDelete: 'CASCADE'
})
ByAccount: Awaited<AccountModel>
declare ByAccount: Awaited<AccountModel>
@ForeignKey(() => AccountModel)
@Column
targetAccountId: number
declare targetAccountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -55,7 +54,7 @@ export class AccountBlocklistModel extends SequelizeModel<AccountBlocklistModel>
as: 'BlockedAccount',
onDelete: 'CASCADE'
})
BlockedAccount: Awaited<AccountModel>
declare BlockedAccount: Awaited<AccountModel>
static isAccountMutedByAccounts (accountIds: number[], targetAccountId: number) {
const query = {
@ -206,7 +205,7 @@ export class AccountBlocklistModel extends SequelizeModel<AccountBlocklistModel>
.map(h => h.name)
const remoteHandles = sanitizedHandles.filter(h => !!h.host)
.map(h => ([ h.name, h.host ]))
.map(h => [ h.name, h.host ])
const handlesWhere: string[] = []

View file

@ -42,25 +42,24 @@ import { AccountModel } from './account.js'
]
})
export class AccountVideoRateModel extends SequelizeModel<AccountVideoRateModel> {
@AllowNull(false)
@Column(DataType.ENUM(...Object.values(VIDEO_RATE_TYPES)))
type: VideoRateType
declare type: VideoRateType
@AllowNull(false)
@Is('AccountVideoRateUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_RATES.URL.max))
url: string
declare url: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -68,11 +67,11 @@ export class AccountVideoRateModel extends SequelizeModel<AccountVideoRateModel>
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@ForeignKey(() => AccountModel)
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -80,7 +79,7 @@ export class AccountVideoRateModel extends SequelizeModel<AccountVideoRateModel>
},
onDelete: 'CASCADE'
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
static load (accountId: number, videoId: number, transaction?: Transaction): Promise<MAccountVideoRate> {
const options: FindOptions = {

View file

@ -151,23 +151,23 @@ export type SummaryOptions = {
export class AccountModel extends SequelizeModel<AccountModel> {
@AllowNull(false)
@Column
name: string
declare name: string
@AllowNull(true)
@Default(null)
@Is('AccountDescription', value => throwIfNotValid(value, isAccountDescriptionValid, 'description', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max))
description: string
declare description: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => ActorModel)
@Column
actorId: number
declare actorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
@ -175,11 +175,11 @@ export class AccountModel extends SequelizeModel<AccountModel> {
},
onDelete: 'cascade'
})
Actor: Awaited<ActorModel>
declare Actor: Awaited<ActorModel>
@ForeignKey(() => UserModel)
@Column
userId: number
declare userId: number
@BelongsTo(() => UserModel, {
foreignKey: {
@ -187,11 +187,11 @@ export class AccountModel extends SequelizeModel<AccountModel> {
},
onDelete: 'cascade'
})
User: Awaited<UserModel>
declare User: Awaited<UserModel>
@ForeignKey(() => ApplicationModel)
@Column
applicationId: number
declare applicationId: number
@BelongsTo(() => ApplicationModel, {
foreignKey: {
@ -199,7 +199,7 @@ export class AccountModel extends SequelizeModel<AccountModel> {
},
onDelete: 'cascade'
})
Application: Awaited<ApplicationModel>
declare Application: Awaited<ApplicationModel>
@HasMany(() => VideoChannelModel, {
foreignKey: {
@ -208,7 +208,7 @@ export class AccountModel extends SequelizeModel<AccountModel> {
onDelete: 'cascade',
hooks: true
})
VideoChannels: Awaited<VideoChannelModel>[]
declare VideoChannels: Awaited<VideoChannelModel>[]
@HasMany(() => VideoPlaylistModel, {
foreignKey: {
@ -217,7 +217,7 @@ export class AccountModel extends SequelizeModel<AccountModel> {
onDelete: 'cascade',
hooks: true
})
VideoPlaylists: Awaited<VideoPlaylistModel>[]
declare VideoPlaylists: Awaited<VideoPlaylistModel>[]
@HasMany(() => VideoCommentModel, {
foreignKey: {
@ -226,7 +226,7 @@ export class AccountModel extends SequelizeModel<AccountModel> {
onDelete: 'cascade',
hooks: true
})
VideoComments: Awaited<VideoCommentModel>[]
declare VideoComments: Awaited<VideoCommentModel>[]
@HasMany(() => AccountBlocklistModel, {
foreignKey: {
@ -236,7 +236,7 @@ export class AccountModel extends SequelizeModel<AccountModel> {
as: 'BlockedBy',
onDelete: 'CASCADE'
})
BlockedBy: Awaited<AccountBlocklistModel>[]
declare BlockedBy: Awaited<AccountBlocklistModel>[]
@HasMany(() => AccountAutomaticTagPolicyModel, {
foreignKey: {
@ -245,19 +245,19 @@ export class AccountModel extends SequelizeModel<AccountModel> {
},
onDelete: 'cascade'
})
AccountAutomaticTagPolicies: Awaited<AccountAutomaticTagPolicyModel>[]
declare AccountAutomaticTagPolicies: Awaited<AccountAutomaticTagPolicyModel>[]
@HasMany(() => CommentAutomaticTagModel, {
foreignKey: 'accountId',
onDelete: 'CASCADE'
})
CommentAutomaticTags: Awaited<CommentAutomaticTagModel>[]
declare CommentAutomaticTags: Awaited<CommentAutomaticTagModel>[]
@HasMany(() => VideoAutomaticTagModel, {
foreignKey: 'accountId',
onDelete: 'CASCADE'
})
VideoAutomaticTags: Awaited<VideoAutomaticTagModel>[]
declare VideoAutomaticTags: Awaited<VideoAutomaticTagModel>[]
@BeforeDestroy
static async sendDeleteIfOwned (instance: AccountModel, options) {

View file

@ -14,24 +14,23 @@ import { SequelizeModel } from '../shared/index.js'
]
})
export class ActorCustomPageModel extends SequelizeModel<ActorCustomPageModel> {
@AllowNull(true)
@Column(DataType.TEXT)
content: string
declare content: string
@AllowNull(false)
@Column
type: 'homepage'
declare type: 'homepage'
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => ActorModel)
@Column
actorId: number
declare actorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
@ -40,7 +39,7 @@ export class ActorCustomPageModel extends SequelizeModel<ActorCustomPageModel> {
},
onDelete: 'cascade'
})
Actor: Awaited<ActorModel>
declare Actor: Awaited<ActorModel>
static async updateInstanceHomepage (content: string) {
const serverActor = await getServerActor()

View file

@ -73,30 +73,30 @@ import { InstanceListFollowingQueryBuilder, ListFollowingOptions } from './sql/i
export class ActorFollowModel extends SequelizeModel<ActorFollowModel> {
@AllowNull(false)
@Column(DataType.ENUM(...Object.values(FOLLOW_STATES)))
state: FollowState
declare state: FollowState
@AllowNull(false)
@Default(ACTOR_FOLLOW_SCORE.BASE)
@IsInt
@Max(ACTOR_FOLLOW_SCORE.MAX)
@Column
score: number
declare score: number
// Allow null because we added this column in PeerTube v3, and don't want to generate fake URLs of remote follows
@AllowNull(true)
@Is('ActorFollowUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))
url: string
declare url: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => ActorModel)
@Column
actorId: number
declare actorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
@ -106,11 +106,11 @@ export class ActorFollowModel extends SequelizeModel<ActorFollowModel> {
as: 'ActorFollower',
onDelete: 'CASCADE'
})
ActorFollower: Awaited<ActorModel>
declare ActorFollower: Awaited<ActorModel>
@ForeignKey(() => ActorModel)
@Column
targetActorId: number
declare targetActorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
@ -120,7 +120,7 @@ export class ActorFollowModel extends SequelizeModel<ActorFollowModel> {
as: 'ActorFollowing',
onDelete: 'CASCADE'
})
ActorFollowing: Awaited<ActorModel>
declare ActorFollowing: Awaited<ActorModel>
@AfterCreate
static incrementFollowerAndFollowingCount (instance: ActorFollowModel, options: any) {

View file

@ -27,39 +27,39 @@ import { ActorModel } from './actor.js'
export class ActorImageModel extends SequelizeModel<ActorImageModel> {
@AllowNull(false)
@Column
filename: string
declare filename: string
@AllowNull(true)
@Default(null)
@Column
height: number
declare height: number
@AllowNull(true)
@Default(null)
@Column
width: number
declare width: number
@AllowNull(true)
@Column
fileUrl: string
declare fileUrl: string
@AllowNull(false)
@Column
onDisk: boolean
declare onDisk: boolean
@AllowNull(false)
@Column
type: ActorImageType_Type
declare type: ActorImageType_Type
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => ActorModel)
@Column
actorId: number
declare actorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
@ -67,7 +67,7 @@ export class ActorImageModel extends SequelizeModel<ActorImageModel> {
},
onDelete: 'CASCADE'
})
Actor: Awaited<ActorModel> // TODO: Remove awaited: https://github.com/sequelize/sequelize-typescript/issues/825
declare Actor: Awaited<ActorModel> // TODO: Remove awaited: https://github.com/sequelize/sequelize-typescript/issues/825
@AfterDestroy
static removeFile (instance: ActorImageModel) {

View file

@ -158,72 +158,72 @@ export const unusedActorAttributesForAPI: (keyof AttributesOnly<ActorModel>)[] =
export class ActorModel extends SequelizeModel<ActorModel> {
@AllowNull(false)
@Column(DataType.ENUM(...Object.values(ACTIVITY_PUB_ACTOR_TYPES)))
type: ActivityPubActorType
declare type: ActivityPubActorType
@AllowNull(false)
@Is('ActorPreferredUsername', value => throwIfNotValid(value, isActorPreferredUsernameValid, 'actor preferred username'))
@Column
preferredUsername: string
declare preferredUsername: string
@AllowNull(false)
@Is('ActorUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
url: string
declare url: string
@AllowNull(true)
@Is('ActorPublicKey', value => throwIfNotValid(value, isActorPublicKeyValid, 'public key', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY.max))
publicKey: string
declare publicKey: string
@AllowNull(true)
@Is('ActorPublicKey', value => throwIfNotValid(value, isActorPrivateKeyValid, 'private key', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY.max))
privateKey: string
declare privateKey: string
@AllowNull(false)
@Is('ActorFollowersCount', value => throwIfNotValid(value, isActorFollowersCountValid, 'followers count'))
@Column
followersCount: number
declare followersCount: number
@AllowNull(false)
@Is('ActorFollowersCount', value => throwIfNotValid(value, isActorFollowingCountValid, 'following count'))
@Column
followingCount: number
declare followingCount: number
@AllowNull(false)
@Is('ActorInboxUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'inbox url'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
inboxUrl: string
declare inboxUrl: string
@AllowNull(true)
@Is('ActorOutboxUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'outbox url', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
outboxUrl: string
declare outboxUrl: string
@AllowNull(true)
@Is('ActorSharedInboxUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'shared inbox url', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
sharedInboxUrl: string
declare sharedInboxUrl: string
@AllowNull(true)
@Is('ActorFollowersUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'followers url', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
followersUrl: string
declare followersUrl: string
@AllowNull(true)
@Is('ActorFollowingUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'following url', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
followingUrl: string
declare followingUrl: string
@AllowNull(true)
@Column
remoteCreatedAt: Date
declare remoteCreatedAt: Date
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@HasMany(() => ActorImageModel, {
as: 'Avatars',
@ -236,7 +236,7 @@ export class ActorModel extends SequelizeModel<ActorModel> {
type: ActorImageType.AVATAR
}
})
Avatars: Awaited<ActorImageModel>[]
declare Avatars: Awaited<ActorImageModel>[]
@HasMany(() => ActorImageModel, {
as: 'Banners',
@ -249,7 +249,7 @@ export class ActorModel extends SequelizeModel<ActorModel> {
type: ActorImageType.BANNER
}
})
Banners: Awaited<ActorImageModel>[]
declare Banners: Awaited<ActorImageModel>[]
@HasMany(() => UploadImageModel, {
as: 'UploadImages',
@ -259,7 +259,7 @@ export class ActorModel extends SequelizeModel<ActorModel> {
allowNull: false
}
})
UploadImages: Awaited<UploadImageModel>[]
declare UploadImages: Awaited<UploadImageModel>[]
@HasMany(() => ActorFollowModel, {
foreignKey: {
@ -269,7 +269,7 @@ export class ActorModel extends SequelizeModel<ActorModel> {
as: 'ActorFollowings',
onDelete: 'cascade'
})
ActorFollowing: Awaited<ActorFollowModel>[]
declare ActorFollowing: Awaited<ActorFollowModel>[]
@HasMany(() => ActorFollowModel, {
foreignKey: {
@ -279,11 +279,11 @@ export class ActorModel extends SequelizeModel<ActorModel> {
as: 'ActorFollowers',
onDelete: 'cascade'
})
ActorFollowers: Awaited<ActorFollowModel>[]
declare ActorFollowers: Awaited<ActorFollowModel>[]
@ForeignKey(() => ServerModel)
@Column
serverId: number
declare serverId: number
@BelongsTo(() => ServerModel, {
foreignKey: {
@ -291,7 +291,7 @@ export class ActorModel extends SequelizeModel<ActorModel> {
},
onDelete: 'cascade'
})
Server: Awaited<ServerModel>
declare Server: Awaited<ServerModel>
@HasOne(() => AccountModel, {
foreignKey: {
@ -300,7 +300,7 @@ export class ActorModel extends SequelizeModel<ActorModel> {
onDelete: 'cascade',
hooks: true
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
@HasOne(() => VideoChannelModel, {
foreignKey: {
@ -309,7 +309,7 @@ export class ActorModel extends SequelizeModel<ActorModel> {
onDelete: 'cascade',
hooks: true
})
VideoChannel: Awaited<VideoChannelModel>
declare VideoChannel: Awaited<VideoChannelModel>
// ---------------------------------------------------------------------------

View file

@ -40,19 +40,19 @@ export class ApplicationModel extends SequelizeModel<ApplicationModel> {
@Default(0)
@IsInt
@Column
migrationVersion: number
declare migrationVersion: number
@AllowNull(true)
@Column
latestPeerTubeVersion: string
declare latestPeerTubeVersion: string
@AllowNull(false)
@Column
nodeVersion: string
declare nodeVersion: string
@AllowNull(false)
@Column
nodeABIVersion: number
declare nodeABIVersion: number
@HasOne(() => AccountModel, {
foreignKey: {
@ -60,7 +60,7 @@ export class ApplicationModel extends SequelizeModel<ApplicationModel> {
},
onDelete: 'cascade'
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
static countTotal () {
return ApplicationModel.count()

View file

@ -28,35 +28,35 @@ import { SequelizeModel } from '../shared/index.js'
export class UploadImageModel extends SequelizeModel<UploadImageModel> {
@AllowNull(false)
@Column
filename: string
declare filename: string
@AllowNull(true)
@Default(null)
@Column
height: number
declare height: number
@AllowNull(true)
@Default(null)
@Column
width: number
declare width: number
@AllowNull(true)
@Column
fileUrl: string
declare fileUrl: string
@AllowNull(false)
@Column
type: UploadImageType_Type
declare type: UploadImageType_Type
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => ActorModel)
@Column
actorId: number
declare actorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
@ -64,7 +64,7 @@ export class UploadImageModel extends SequelizeModel<UploadImageModel> {
},
onDelete: 'CASCADE'
})
Actor: Awaited<ActorModel>
declare Actor: Awaited<ActorModel>
@AfterDestroy
static removeFile (instance: UploadImageModel) {

View file

@ -17,18 +17,18 @@ import { AutomaticTagModel } from './automatic-tag.js'
})
export class AccountAutomaticTagPolicyModel extends SequelizeModel<AccountAutomaticTagPolicyModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(true)
@Column(DataType.INTEGER)
policy: AutomaticTagPolicyType
declare policy: AutomaticTagPolicyType
@ForeignKey(() => AccountModel)
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -36,11 +36,11 @@ export class AccountAutomaticTagPolicyModel extends SequelizeModel<AccountAutoma
},
onDelete: 'cascade'
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
@ForeignKey(() => AutomaticTagModel)
@Column
automaticTagId: number
declare automaticTagId: number
@BelongsTo(() => AutomaticTagModel, {
foreignKey: {
@ -48,7 +48,7 @@ export class AccountAutomaticTagPolicyModel extends SequelizeModel<AccountAutoma
},
onDelete: 'cascade'
})
AutomaticTag: Awaited<AutomaticTagModel>
declare AutomaticTag: Awaited<AutomaticTagModel>
static async listOfAccount (account: MAccountId) {
const rows = await this.findAll({

View file

@ -21,22 +21,21 @@ import { VideoAutomaticTagModel } from './video-automatic-tag.js'
]
})
export class AutomaticTagModel extends SequelizeModel<AutomaticTagModel> {
@AllowNull(false)
@Column
name: string
declare name: string
@HasMany(() => CommentAutomaticTagModel, {
foreignKey: 'automaticTagId',
onDelete: 'CASCADE'
})
CommentAutomaticTags: Awaited<CommentAutomaticTagModel>[]
declare CommentAutomaticTags: Awaited<CommentAutomaticTagModel>[]
@HasMany(() => VideoAutomaticTagModel, {
foreignKey: 'automaticTagId',
onDelete: 'CASCADE'
})
VideoAutomaticTags: Awaited<VideoAutomaticTagModel>[]
declare VideoAutomaticTags: Awaited<VideoAutomaticTagModel>[]
@HasMany(() => AccountAutomaticTagPolicyModel, {
foreignKey: {
@ -45,7 +44,7 @@ export class AutomaticTagModel extends SequelizeModel<AutomaticTagModel> {
},
onDelete: 'cascade'
})
AccountAutomaticTagPolicies: Awaited<AccountAutomaticTagPolicyModel>[]
declare AccountAutomaticTagPolicies: Awaited<AccountAutomaticTagPolicyModel>[]
static findOrCreateAutomaticTag (options: {
tag: string

View file

@ -6,10 +6,8 @@ import { AutomaticTagModel } from './automatic-tag.js'
import { Transaction } from 'sequelize'
/**
*
* Sequelize doesn't seem to support many to many relation using BelongsToMany with 3 tables
* So we reproduce the behaviour with classic BelongsTo/HasMany relations
*
*/
@Table({
@ -17,25 +15,25 @@ import { Transaction } from 'sequelize'
})
export class CommentAutomaticTagModel extends SequelizeModel<CommentAutomaticTagModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoCommentModel)
@PrimaryKey
@Column
commentId: number
declare commentId: number
@ForeignKey(() => AutomaticTagModel)
@PrimaryKey
@Column
automaticTagId: number
declare automaticTagId: number
@ForeignKey(() => AccountModel)
@PrimaryKey
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -43,7 +41,7 @@ export class CommentAutomaticTagModel extends SequelizeModel<CommentAutomaticTag
},
onDelete: 'CASCADE'
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
@BelongsTo(() => AutomaticTagModel, {
foreignKey: {
@ -51,7 +49,7 @@ export class CommentAutomaticTagModel extends SequelizeModel<CommentAutomaticTag
},
onDelete: 'CASCADE'
})
AutomaticTag: Awaited<AutomaticTagModel>
declare AutomaticTag: Awaited<AutomaticTagModel>
@BelongsTo(() => VideoCommentModel, {
foreignKey: {
@ -59,7 +57,7 @@ export class CommentAutomaticTagModel extends SequelizeModel<CommentAutomaticTag
},
onDelete: 'CASCADE'
})
VideoComment: Awaited<VideoCommentModel>
declare VideoComment: Awaited<VideoCommentModel>
static deleteAllOfAccountAndComment (options: {
accountId: number

View file

@ -6,10 +6,8 @@ import { VideoModel } from '../video/video.js'
import { AutomaticTagModel } from './automatic-tag.js'
/**
*
* Sequelize doesn't seem to support many to many relation using BelongsToMany with 3 tables
* So we reproduce the behaviour with classic BelongsTo/HasMany relations
*
*/
@Table({
@ -17,25 +15,25 @@ import { AutomaticTagModel } from './automatic-tag.js'
})
export class VideoAutomaticTagModel extends SequelizeModel<VideoAutomaticTagModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoModel)
@PrimaryKey
@Column
videoId: number
declare videoId: number
@ForeignKey(() => AutomaticTagModel)
@PrimaryKey
@Column
automaticTagId: number
declare automaticTagId: number
@ForeignKey(() => AccountModel)
@PrimaryKey
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -43,7 +41,7 @@ export class VideoAutomaticTagModel extends SequelizeModel<VideoAutomaticTagMode
},
onDelete: 'CASCADE'
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
@BelongsTo(() => AutomaticTagModel, {
foreignKey: {
@ -51,7 +49,7 @@ export class VideoAutomaticTagModel extends SequelizeModel<VideoAutomaticTagMode
},
onDelete: 'CASCADE'
})
AutomaticTag: Awaited<AutomaticTagModel>
declare AutomaticTag: Awaited<AutomaticTagModel>
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -59,7 +57,7 @@ export class VideoAutomaticTagModel extends SequelizeModel<VideoAutomaticTagMode
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static deleteAllOfAccountAndVideo (options: {
accountId: number

View file

@ -16,31 +16,30 @@ import { SequelizeModel } from '../shared/index.js'
]
})
export class OAuthClientModel extends SequelizeModel<OAuthClientModel> {
@AllowNull(false)
@Column
declare clientId: string
@AllowNull(false)
@Column
clientId: string
@AllowNull(false)
@Column
clientSecret: string
declare clientSecret: string
@Column(DataType.ARRAY(DataType.STRING))
grants: string[]
declare grants: string[]
@Column(DataType.ARRAY(DataType.STRING))
redirectUris: string[]
declare redirectUris: string[]
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@HasMany(() => OAuthTokenModel, {
onDelete: 'cascade'
})
OAuthTokens: Awaited<OAuthTokenModel>[]
declare OAuthTokens: Awaited<OAuthTokenModel>[]
static countTotal () {
return OAuthClientModel.count()

View file

@ -6,7 +6,8 @@ import {
BelongsTo,
Column,
CreatedAt,
ForeignKey, Scopes,
ForeignKey,
Scopes,
Table,
UpdatedAt
} from 'sequelize-typescript'
@ -79,35 +80,34 @@ enum ScopeNames {
]
})
export class OAuthTokenModel extends SequelizeModel<OAuthTokenModel> {
@AllowNull(false)
@Column
declare accessToken: string
@AllowNull(false)
@Column
accessToken: string
declare accessTokenExpiresAt: Date
@AllowNull(false)
@Column
accessTokenExpiresAt: Date
declare refreshToken: string
@AllowNull(false)
@Column
refreshToken: string
@AllowNull(false)
@Column
refreshTokenExpiresAt: Date
declare refreshTokenExpiresAt: Date
@Column
authName: string
declare authName: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => UserModel)
@Column
userId: number
declare userId: number
@BelongsTo(() => UserModel, {
foreignKey: {
@ -115,11 +115,11 @@ export class OAuthTokenModel extends SequelizeModel<OAuthTokenModel> {
},
onDelete: 'cascade'
})
User: Awaited<UserModel>
declare User: Awaited<UserModel>
@ForeignKey(() => OAuthClientModel)
@Column
oAuthClientId: number
declare oAuthClientId: number
@BelongsTo(() => OAuthClientModel, {
foreignKey: {
@ -127,7 +127,7 @@ export class OAuthTokenModel extends SequelizeModel<OAuthTokenModel> {
},
onDelete: 'cascade'
})
OAuthClients: Awaited<OAuthClientModel>[]
declare OAuthClients: Awaited<OAuthClientModel>[]
@AfterUpdate
@AfterDestroy

View file

@ -78,31 +78,31 @@ export enum ScopeNames {
})
export class VideoRedundancyModel extends SequelizeModel<VideoRedundancyModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(true)
@Column
expiresOn: Date
declare expiresOn: Date
@AllowNull(false)
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS_REDUNDANCY.URL.max))
fileUrl: string
declare fileUrl: string
@AllowNull(false)
@Is('VideoRedundancyUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS_REDUNDANCY.URL.max))
url: string
declare url: string
@AllowNull(true)
@Column
strategy: string // Only used by us
declare strategy: string // Only used by us
@ForeignKey(() => VideoStreamingPlaylistModel)
@Column
videoStreamingPlaylistId: number
declare videoStreamingPlaylistId: number
@BelongsTo(() => VideoStreamingPlaylistModel, {
foreignKey: {
@ -110,11 +110,11 @@ export class VideoRedundancyModel extends SequelizeModel<VideoRedundancyModel> {
},
onDelete: 'cascade'
})
VideoStreamingPlaylist: Awaited<VideoStreamingPlaylistModel>
declare VideoStreamingPlaylist: Awaited<VideoStreamingPlaylistModel>
@ForeignKey(() => ActorModel)
@Column
actorId: number
declare actorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
@ -122,7 +122,7 @@ export class VideoRedundancyModel extends SequelizeModel<VideoRedundancyModel> {
},
onDelete: 'cascade'
})
Actor: Awaited<ActorModel>
declare Actor: Awaited<ActorModel>
@BeforeDestroy
static async removeFile (instance: VideoRedundancyModel) {

View file

@ -19,7 +19,8 @@ import {
DataType,
Default,
ForeignKey,
IsUUID, Scopes,
IsUUID,
Scopes,
Table,
UpdatedAt
} from 'sequelize-typescript'
@ -66,68 +67,67 @@ enum ScopeNames {
]
})
export class RunnerJobModel extends SequelizeModel<RunnerJobModel> {
@AllowNull(false)
@IsUUID(4)
@Column(DataType.UUID)
uuid: string
declare uuid: string
@AllowNull(false)
@Column
type: RunnerJobType
declare type: RunnerJobType
@AllowNull(false)
@Column(DataType.JSONB)
payload: RunnerJobPayload
declare payload: RunnerJobPayload
@AllowNull(false)
@Column(DataType.JSONB)
privatePayload: RunnerJobPrivatePayload
declare privatePayload: RunnerJobPrivatePayload
@AllowNull(false)
@Column
state: RunnerJobStateType
declare state: RunnerJobStateType
@AllowNull(false)
@Default(0)
@Column
failures: number
declare failures: number
@AllowNull(true)
@Column(DataType.STRING(CONSTRAINTS_FIELDS.RUNNER_JOBS.ERROR_MESSAGE.max))
error: string
declare error: string
// Less has priority
@AllowNull(false)
@Column
priority: number
declare priority: number
// Used to fetch the appropriate job when the runner wants to post the result
@AllowNull(true)
@Column
processingJobToken: string
declare processingJobToken: string
@AllowNull(true)
@Column
progress: number
declare progress: number
@AllowNull(true)
@Column
startedAt: Date
declare startedAt: Date
@AllowNull(true)
@Column
finishedAt: Date
declare finishedAt: Date
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => RunnerJobModel)
@Column
dependsOnRunnerJobId: number
declare dependsOnRunnerJobId: number
@BelongsTo(() => RunnerJobModel, {
foreignKey: {
@ -136,11 +136,11 @@ export class RunnerJobModel extends SequelizeModel<RunnerJobModel> {
},
onDelete: 'cascade'
})
DependsOnRunnerJob: Awaited<RunnerJobModel>
declare DependsOnRunnerJob: Awaited<RunnerJobModel>
@ForeignKey(() => RunnerModel)
@Column
runnerId: number
declare runnerId: number
@BelongsTo(() => RunnerModel, {
foreignKey: {
@ -149,7 +149,7 @@ export class RunnerJobModel extends SequelizeModel<RunnerJobModel> {
},
onDelete: 'SET NULL'
})
Runner: Awaited<RunnerModel>
declare Runner: Awaited<RunnerModel>
// ---------------------------------------------------------------------------
@ -309,7 +309,11 @@ export class RunnerJobModel extends SequelizeModel<RunnerJobModel> {
setToErrorOrCancel (
// eslint-disable-next-line max-len
state: typeof RunnerJobState.PARENT_ERRORED | typeof RunnerJobState.ERRORED | typeof RunnerJobState.CANCELLED | typeof RunnerJobState.PARENT_CANCELLED
state:
| typeof RunnerJobState.PARENT_ERRORED
| typeof RunnerJobState.ERRORED
| typeof RunnerJobState.CANCELLED
| typeof RunnerJobState.PARENT_CANCELLED
) {
this.state = state
this.processingJobToken = null

View file

@ -6,9 +6,7 @@ import { SequelizeModel, getSort } from '../shared/index.js'
import { RunnerModel } from './runner.js'
/**
*
* Tokens used by PeerTube runners to register themselves to the PeerTube instance
*
*/
@Table({
@ -21,16 +19,15 @@ import { RunnerModel } from './runner.js'
]
})
export class RunnerRegistrationTokenModel extends SequelizeModel<RunnerRegistrationTokenModel> {
@AllowNull(false)
@Column
registrationToken: string
declare registrationToken: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@HasMany(() => RunnerModel, {
foreignKey: {
@ -38,7 +35,7 @@ export class RunnerRegistrationTokenModel extends SequelizeModel<RunnerRegistrat
},
onDelete: 'cascade'
})
Runners: Awaited<RunnerModel>[]
declare Runners: Awaited<RunnerModel>[]
static load (id: number) {
return RunnerRegistrationTokenModel.findByPk(id)

View file

@ -23,37 +23,36 @@ import { CONSTRAINTS_FIELDS } from '@server/initializers/constants.js'
]
})
export class RunnerModel extends SequelizeModel<RunnerModel> {
// Used to identify the appropriate runner when it uses the runner REST API
@AllowNull(false)
@Column
runnerToken: string
declare runnerToken: string
@AllowNull(false)
@Column
name: string
declare name: string
@AllowNull(true)
@Column(DataType.STRING(CONSTRAINTS_FIELDS.RUNNERS.DESCRIPTION.max))
description: string
declare description: string
@AllowNull(false)
@Column
lastContact: Date
declare lastContact: Date
@AllowNull(false)
@Column
ip: string
declare ip: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => RunnerRegistrationTokenModel)
@Column
runnerRegistrationTokenId: number
declare runnerRegistrationTokenId: number
@BelongsTo(() => RunnerRegistrationTokenModel, {
foreignKey: {
@ -61,7 +60,7 @@ export class RunnerModel extends SequelizeModel<RunnerModel> {
},
onDelete: 'cascade'
})
RunnerRegistrationToken: Awaited<RunnerRegistrationTokenModel>
declare RunnerRegistrationToken: Awaited<RunnerRegistrationTokenModel>
// ---------------------------------------------------------------------------

View file

@ -24,7 +24,6 @@ import { SequelizeModel, getSort, throwIfNotValid } from '../shared/index.js'
exclude: [ 'storage' ]
}
}))
@Table({
tableName: 'plugin',
indexes: [
@ -35,62 +34,61 @@ import { SequelizeModel, getSort, throwIfNotValid } from '../shared/index.js'
]
})
export class PluginModel extends SequelizeModel<PluginModel> {
@AllowNull(false)
@Is('PluginName', value => throwIfNotValid(value, isPluginNameValid, 'name'))
@Column
name: string
declare name: string
@AllowNull(false)
@Is('PluginType', value => throwIfNotValid(value, isPluginTypeValid, 'type'))
@Column
type: PluginType_Type
declare type: PluginType_Type
@AllowNull(false)
@Is('PluginVersion', value => throwIfNotValid(value, isPluginStableOrUnstableVersionValid, 'version'))
@Column
version: string
declare version: string
@AllowNull(true)
@Is('PluginLatestVersion', value => throwIfNotValid(value, isPluginStableVersionValid, 'version'))
@Column
latestVersion: string
declare latestVersion: string
@AllowNull(false)
@Column
enabled: boolean
declare enabled: boolean
@AllowNull(false)
@Column
uninstalled: boolean
declare uninstalled: boolean
@AllowNull(false)
@Column
peertubeEngine: string
declare peertubeEngine: string
@AllowNull(true)
@Is('PluginDescription', value => throwIfNotValid(value, isPluginDescriptionValid, 'description'))
@Column
description: string
declare description: string
@AllowNull(false)
@Is('PluginHomepage', value => throwIfNotValid(value, isPluginHomepage, 'homepage'))
@Column
homepage: string
declare homepage: string
@AllowNull(true)
@Column(DataType.JSONB)
settings: any
declare settings: any
@AllowNull(true)
@Column(DataType.JSONB)
storage: any
declare storage: any
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
static listEnabledPluginsAndThemes (): Promise<MPlugin[]> {
const query = {
@ -312,5 +310,4 @@ export class PluginModel extends SequelizeModel<PluginModel> {
updatedAt: this.updatedAt
}
}
}

View file

@ -29,7 +29,6 @@ enum ScopeNames {
]
}
}))
@Table({
tableName: 'serverBlocklist',
indexes: [
@ -43,16 +42,15 @@ enum ScopeNames {
]
})
export class ServerBlocklistModel extends SequelizeModel<ServerBlocklistModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => AccountModel)
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -61,11 +59,11 @@ export class ServerBlocklistModel extends SequelizeModel<ServerBlocklistModel> {
},
onDelete: 'CASCADE'
})
ByAccount: Awaited<AccountModel>
declare ByAccount: Awaited<AccountModel>
@ForeignKey(() => ServerModel)
@Column
targetServerId: number
declare targetServerId: number
@BelongsTo(() => ServerModel, {
foreignKey: {
@ -73,7 +71,7 @@ export class ServerBlocklistModel extends SequelizeModel<ServerBlocklistModel> {
},
onDelete: 'CASCADE'
})
BlockedServer: Awaited<ServerModel>
declare BlockedServer: Awaited<ServerModel>
static isServerMutedByAccounts (accountIds: number[], targetServerId: number) {
const query = {

View file

@ -16,22 +16,21 @@ import { ServerBlocklistModel } from './server-blocklist.js'
]
})
export class ServerModel extends SequelizeModel<ServerModel> {
@AllowNull(false)
@Is('Host', value => throwIfNotValid(value, isHostValid, 'valid host'))
@Column
host: string
declare host: string
@AllowNull(false)
@Default(false)
@Column
redundancyAllowed: boolean
declare redundancyAllowed: boolean
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@HasMany(() => ActorModel, {
foreignKey: {
@ -41,7 +40,7 @@ export class ServerModel extends SequelizeModel<ServerModel> {
onDelete: 'CASCADE',
hooks: true
})
Actors: Awaited<ActorModel>[]
declare Actors: Awaited<ActorModel>[]
@HasMany(() => ServerBlocklistModel, {
foreignKey: {
@ -49,7 +48,7 @@ export class ServerModel extends SequelizeModel<ServerModel> {
},
onDelete: 'CASCADE'
})
BlockedBy: Awaited<ServerBlocklistModel>[]
declare BlockedBy: Awaited<ServerBlocklistModel>[]
// ---------------------------------------------------------------------------

View file

@ -15,23 +15,22 @@ import { SequelizeModel } from '../shared/sequelize-type.js'
]
})
export class TrackerModel extends SequelizeModel<TrackerModel> {
@AllowNull(false)
@Column
url: string
declare url: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@BelongsToMany(() => VideoModel, {
foreignKey: 'trackerId',
through: () => VideoTrackerModel,
onDelete: 'CASCADE'
})
Videos: Awaited<VideoModel>[]
declare Videos: Awaited<VideoModel>[]
static listUrlsByVideoId (videoId: number) {
const query = {

View file

@ -16,16 +16,16 @@ import { SequelizeModel } from '../shared/index.js'
})
export class VideoTrackerModel extends SequelizeModel<VideoTrackerModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@ForeignKey(() => TrackerModel)
@Column
trackerId: number
declare trackerId: number
}

View file

@ -2,5 +2,5 @@ import { AttributesOnly } from '@peertube/peertube-typescript-utils'
import { Model } from 'sequelize-typescript'
export abstract class SequelizeModel<T> extends Model<Partial<AttributesOnly<T>>> {
id: number
declare id: number
}

View file

@ -35,42 +35,42 @@ import { UserModel } from './user.js'
})
export class UserExportModel extends SequelizeModel<UserExportModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(true)
@Column
filename: string
declare filename: string
@AllowNull(false)
@Column
withVideoFiles: boolean
declare withVideoFiles: boolean
@AllowNull(false)
@Column
state: UserExportStateType
declare state: UserExportStateType
@AllowNull(true)
@Column(DataType.TEXT)
error: string
declare error: string
@AllowNull(true)
@Column(DataType.BIGINT)
size: number
declare size: number
@AllowNull(false)
@Column
storage: FileStorageType
declare storage: FileStorageType
@AllowNull(true)
@Column
fileUrl: string
declare fileUrl: string
@ForeignKey(() => UserModel)
@Column
userId: number
declare userId: number
@BelongsTo(() => UserModel, {
foreignKey: {
@ -78,7 +78,7 @@ export class UserExportModel extends SequelizeModel<UserExportModel> {
},
onDelete: 'CASCADE'
})
User: Awaited<UserModel>
declare User: Awaited<UserModel>
@BeforeDestroy
static removeFile (instance: UserExportModel) {
@ -225,5 +225,4 @@ export class UserExportModel extends SequelizeModel<UserExportModel> {
expiresOn: new Date(this.createdAt.getTime() + CONFIG.EXPORT.USERS.EXPORT_EXPIRATION).toISOString()
}
}
}

View file

@ -20,30 +20,30 @@ import { USER_IMPORT_STATES } from '@server/initializers/constants.js'
})
export class UserImportModel extends SequelizeModel<UserImportModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(true)
@Column
filename: string
declare filename: string
@AllowNull(false)
@Column
state: UserImportStateType
declare state: UserImportStateType
@AllowNull(true)
@Column(DataType.TEXT)
error: string
declare error: string
@AllowNull(true)
@Column(DataType.JSONB)
resultSummary: UserImportResultSummary
declare resultSummary: UserImportResultSummary
@ForeignKey(() => UserModel)
@Column
userId: number
declare userId: number
@BelongsTo(() => UserModel, {
foreignKey: {
@ -51,7 +51,7 @@ export class UserImportModel extends SequelizeModel<UserImportModel> {
},
onDelete: 'CASCADE'
})
User: Awaited<UserModel>
declare User: Awaited<UserModel>
static load (id: number | string) {
return UserImportModel.findByPk<MUserImport>(id)

View file

@ -10,7 +10,8 @@ import {
CreatedAt,
Default,
ForeignKey,
Is, Table,
Is,
Table,
UpdatedAt
} from 'sequelize-typescript'
import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications.js'
@ -27,7 +28,6 @@ import { UserModel } from './user.js'
]
})
export class UserNotificationSettingModel extends SequelizeModel<UserNotificationSettingModel> {
@AllowNull(false)
@Default(null)
@Is(
@ -35,7 +35,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'newVideoFromSubscription')
)
@Column
newVideoFromSubscription: UserNotificationSettingValueType
declare newVideoFromSubscription: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -44,7 +44,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'newCommentOnMyVideo')
)
@Column
newCommentOnMyVideo: UserNotificationSettingValueType
declare newCommentOnMyVideo: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -53,7 +53,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseAsModerator')
)
@Column
abuseAsModerator: UserNotificationSettingValueType
declare abuseAsModerator: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -62,7 +62,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'videoAutoBlacklistAsModerator')
)
@Column
videoAutoBlacklistAsModerator: UserNotificationSettingValueType
declare videoAutoBlacklistAsModerator: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -71,7 +71,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'blacklistOnMyVideo')
)
@Column
blacklistOnMyVideo: UserNotificationSettingValueType
declare blacklistOnMyVideo: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -80,7 +80,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'myVideoPublished')
)
@Column
myVideoPublished: UserNotificationSettingValueType
declare myVideoPublished: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -89,7 +89,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'myVideoImportFinished')
)
@Column
myVideoImportFinished: UserNotificationSettingValueType
declare myVideoImportFinished: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -98,7 +98,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'newUserRegistration')
)
@Column
newUserRegistration: UserNotificationSettingValueType
declare newUserRegistration: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -107,7 +107,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'newInstanceFollower')
)
@Column
newInstanceFollower: UserNotificationSettingValueType
declare newInstanceFollower: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -116,7 +116,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'autoInstanceFollowing')
)
@Column
autoInstanceFollowing: UserNotificationSettingValueType
declare autoInstanceFollowing: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -125,7 +125,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'newFollow')
)
@Column
newFollow: UserNotificationSettingValueType
declare newFollow: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -134,7 +134,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'commentMention')
)
@Column
commentMention: UserNotificationSettingValueType
declare commentMention: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -143,7 +143,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseStateChange')
)
@Column
abuseStateChange: UserNotificationSettingValueType
declare abuseStateChange: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -152,7 +152,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseNewMessage')
)
@Column
abuseNewMessage: UserNotificationSettingValueType
declare abuseNewMessage: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -161,7 +161,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'newPeerTubeVersion')
)
@Column
newPeerTubeVersion: UserNotificationSettingValueType
declare newPeerTubeVersion: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -170,7 +170,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'newPluginVersion')
)
@Column
newPluginVersion: UserNotificationSettingValueType
declare newPluginVersion: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -179,7 +179,7 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'myVideoStudioEditionFinished')
)
@Column
myVideoStudioEditionFinished: UserNotificationSettingValueType
declare myVideoStudioEditionFinished: UserNotificationSettingValueType
@AllowNull(false)
@Default(null)
@ -188,11 +188,11 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
value => throwIfNotValid(value, isUserNotificationSettingValid, 'myVideoTranscriptionGenerated')
)
@Column
myVideoTranscriptionGenerated: UserNotificationSettingValueType
declare myVideoTranscriptionGenerated: UserNotificationSettingValueType
@ForeignKey(() => UserModel)
@Column
userId: number
declare userId: number
@BelongsTo(() => UserModel, {
foreignKey: {
@ -200,13 +200,13 @@ export class UserNotificationSettingModel extends SequelizeModel<UserNotificatio
},
onDelete: 'cascade'
})
User: Awaited<UserModel>
declare User: Awaited<UserModel>
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AfterUpdate
@AfterDestroy

View file

@ -116,23 +116,23 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
@Default(null)
@Is('UserNotificationType', value => throwIfNotValid(value, isUserNotificationTypeValid, 'type'))
@Column
type: UserNotificationType_Type
declare type: UserNotificationType_Type
@AllowNull(false)
@Default(false)
@Is('UserNotificationRead', value => throwIfNotValid(value, isBooleanValid, 'read'))
@Column
read: boolean
declare read: boolean
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => UserModel)
@Column
userId: number
declare userId: number
@BelongsTo(() => UserModel, {
foreignKey: {
@ -140,11 +140,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
User: Awaited<UserModel>
declare User: Awaited<UserModel>
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -152,11 +152,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@ForeignKey(() => VideoCommentModel)
@Column
commentId: number
declare commentId: number
@BelongsTo(() => VideoCommentModel, {
foreignKey: {
@ -164,11 +164,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
VideoComment: Awaited<VideoCommentModel>
declare VideoComment: Awaited<VideoCommentModel>
@ForeignKey(() => AbuseModel)
@Column
abuseId: number
declare abuseId: number
@BelongsTo(() => AbuseModel, {
foreignKey: {
@ -176,11 +176,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
Abuse: Awaited<AbuseModel>
declare Abuse: Awaited<AbuseModel>
@ForeignKey(() => VideoBlacklistModel)
@Column
videoBlacklistId: number
declare videoBlacklistId: number
@BelongsTo(() => VideoBlacklistModel, {
foreignKey: {
@ -188,11 +188,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
VideoBlacklist: Awaited<VideoBlacklistModel>
declare VideoBlacklist: Awaited<VideoBlacklistModel>
@ForeignKey(() => VideoImportModel)
@Column
videoImportId: number
declare videoImportId: number
@BelongsTo(() => VideoImportModel, {
foreignKey: {
@ -200,11 +200,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
VideoImport: Awaited<VideoImportModel>
declare VideoImport: Awaited<VideoImportModel>
@ForeignKey(() => AccountModel)
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -212,11 +212,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
@ForeignKey(() => ActorFollowModel)
@Column
actorFollowId: number
declare actorFollowId: number
@BelongsTo(() => ActorFollowModel, {
foreignKey: {
@ -224,11 +224,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
ActorFollow: Awaited<ActorFollowModel>
declare ActorFollow: Awaited<ActorFollowModel>
@ForeignKey(() => PluginModel)
@Column
pluginId: number
declare pluginId: number
@BelongsTo(() => PluginModel, {
foreignKey: {
@ -236,11 +236,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
Plugin: Awaited<PluginModel>
declare Plugin: Awaited<PluginModel>
@ForeignKey(() => ApplicationModel)
@Column
applicationId: number
declare applicationId: number
@BelongsTo(() => ApplicationModel, {
foreignKey: {
@ -248,11 +248,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
Application: Awaited<ApplicationModel>
declare Application: Awaited<ApplicationModel>
@ForeignKey(() => UserRegistrationModel)
@Column
userRegistrationId: number
declare userRegistrationId: number
@BelongsTo(() => UserRegistrationModel, {
foreignKey: {
@ -260,11 +260,11 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
UserRegistration: Awaited<UserRegistrationModel>
declare UserRegistration: Awaited<UserRegistrationModel>
@ForeignKey(() => VideoCaptionModel)
@Column
videoCaptionId: number
declare videoCaptionId: number
@BelongsTo(() => VideoCaptionModel, {
foreignKey: {
@ -272,7 +272,7 @@ export class UserNotificationModel extends SequelizeModel<UserNotificationModel>
},
onDelete: 'cascade'
})
VideoCaption: Awaited<VideoCaptionModel>
declare VideoCaption: Awaited<VideoCaptionModel>
static listForApi (options: {
userId: number

View file

@ -18,7 +18,8 @@ import {
DataType,
ForeignKey,
Is,
IsEmail, Table,
IsEmail,
Table,
UpdatedAt
} from 'sequelize-typescript'
import { isUserDisplayNameValid, isUserEmailVerifiedValid, isUserPasswordValid } from '../../helpers/custom-validators/users.js'
@ -48,69 +49,68 @@ import { forceNumber } from '@peertube/peertube-core-utils'
]
})
export class UserRegistrationModel extends SequelizeModel<UserRegistrationModel> {
@AllowNull(false)
@Is('RegistrationState', value => throwIfNotValid(value, isRegistrationStateValid, 'state'))
@Column
state: UserRegistrationStateType
declare state: UserRegistrationStateType
@AllowNull(false)
@Is('RegistrationReason', value => throwIfNotValid(value, isRegistrationReasonValid, 'registration reason'))
@Column(DataType.TEXT)
registrationReason: string
declare registrationReason: string
@AllowNull(true)
@Is('RegistrationModerationResponse', value => throwIfNotValid(value, isRegistrationModerationResponseValid, 'moderation response', true))
@Column(DataType.TEXT)
moderationResponse: string
declare moderationResponse: string
@AllowNull(true)
@Is('RegistrationPassword', value => throwIfNotValid(value, isUserPasswordValid, 'registration password', true))
@Column
password: string
declare password: string
@AllowNull(false)
@Column
username: string
declare username: string
@AllowNull(false)
@IsEmail
@Column(DataType.STRING(400))
email: string
declare email: string
@AllowNull(true)
@Is('RegistrationEmailVerified', value => throwIfNotValid(value, isUserEmailVerifiedValid, 'email verified boolean', true))
@Column
emailVerified: boolean
declare emailVerified: boolean
@AllowNull(true)
@Is('RegistrationAccountDisplayName', value => throwIfNotValid(value, isUserDisplayNameValid, 'account display name', true))
@Column
accountDisplayName: string
declare accountDisplayName: string
@AllowNull(true)
@Is('ChannelHandle', value => throwIfNotValid(value, isVideoChannelDisplayNameValid, 'channel handle', true))
@Column
channelHandle: string
declare channelHandle: string
@AllowNull(true)
@Is('ChannelDisplayName', value => throwIfNotValid(value, isVideoChannelDisplayNameValid, 'channel display name', true))
@Column
channelDisplayName: string
declare channelDisplayName: string
@AllowNull(true)
@Column
processedAt: Date
declare processedAt: Date
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => UserModel)
@Column
userId: number
declare userId: number
@BelongsTo(() => UserModel, {
foreignKey: {
@ -118,7 +118,7 @@ export class UserRegistrationModel extends SequelizeModel<UserRegistrationModel>
},
onDelete: 'SET NULL'
})
User: Awaited<UserModel>
declare User: Awaited<UserModel>
@BeforeCreate
static async cryptPasswordIfNeeded (instance: UserRegistrationModel) {

View file

@ -25,19 +25,19 @@ import { getSort } from '../shared/sort.js'
})
export class UserVideoHistoryModel extends SequelizeModel<UserVideoHistoryModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@IsInt
@Column
currentTime: number
declare currentTime: number
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -45,11 +45,11 @@ export class UserVideoHistoryModel extends SequelizeModel<UserVideoHistoryModel>
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@ForeignKey(() => UserModel)
@Column
userId: number
declare userId: number
@BelongsTo(() => UserModel, {
foreignKey: {
@ -57,7 +57,7 @@ export class UserVideoHistoryModel extends SequelizeModel<UserVideoHistoryModel>
},
onDelete: 'CASCADE'
})
User: Awaited<UserModel>
declare User: Awaited<UserModel>
// FIXME: have to specify the result type to not break peertube typings generation
static listForApi (user: MUserAccountId, start: number, count: number, search?: string): Promise<ResultList<VideoModel>> {

View file

@ -292,79 +292,79 @@ export class UserModel extends SequelizeModel<UserModel> {
@AllowNull(true)
@Is('UserPassword', value => throwIfNotValid(value, isUserPasswordValid, 'user password', true))
@Column
password: string
declare password: string
@AllowNull(false)
@Column
username: string
declare username: string
@AllowNull(false)
@IsEmail
@Column(DataType.STRING(400))
email: string
declare email: string
@AllowNull(true)
@IsEmail
@Column(DataType.STRING(400))
pendingEmail: string
declare pendingEmail: string
@AllowNull(true)
@Default(null)
@Is('UserEmailVerified', value => throwIfNotValid(value, isUserEmailVerifiedValid, 'email verified boolean', true))
@Column
emailVerified: boolean
declare emailVerified: boolean
@AllowNull(false)
@Is('UserNSFWPolicy', value => throwIfNotValid(value, isUserNSFWPolicyValid, 'NSFW policy'))
@Column(DataType.ENUM(...Object.values(NSFW_POLICY_TYPES)))
nsfwPolicy: NSFWPolicyType
declare nsfwPolicy: NSFWPolicyType
@AllowNull(false)
@Default(0)
@Is('UserNSFWFlagsDisplayed', value => throwIfNotValid(value, isNSFWFlagsValid, 'NSFW flags'))
@Column
nsfwFlagsDisplayed: number
declare nsfwFlagsDisplayed: number
@AllowNull(false)
@Default(0)
@Is('UserNSFWFlagsHidden', value => throwIfNotValid(value, isNSFWFlagsValid, 'NSFW flags'))
@Column
nsfwFlagsHidden: number
declare nsfwFlagsHidden: number
@AllowNull(false)
@Default(0)
@Is('nsfwFlagsBlurred', value => throwIfNotValid(value, isNSFWFlagsValid, 'NSFW flags'))
@Column
nsfwFlagsBlurred: number
declare nsfwFlagsBlurred: number
@AllowNull(false)
@Default(0)
@Is('UserNSFWFlagsWarned', value => throwIfNotValid(value, isNSFWFlagsValid, 'NSFW flags'))
@Column
nsfwFlagsWarned: number
declare nsfwFlagsWarned: number
@AllowNull(false)
@Is('p2pEnabled', value => throwIfNotValid(value, isUserP2PEnabledValid, 'P2P enabled'))
@Column
p2pEnabled: boolean
declare p2pEnabled: boolean
@AllowNull(false)
@Default(true)
@Is('UserVideosHistoryEnabled', value => throwIfNotValid(value, isUserVideosHistoryEnabledValid, 'Videos history enabled'))
@Column
videosHistoryEnabled: boolean
declare videosHistoryEnabled: boolean
@AllowNull(false)
@Default(true)
@Is('UserAutoPlayVideo', value => throwIfNotValid(value, isUserAutoPlayVideoValid, 'auto play video boolean'))
@Column
autoPlayVideo: boolean
declare autoPlayVideo: boolean
@AllowNull(false)
@Default(false)
@Is('UserAutoPlayNextVideo', value => throwIfNotValid(value, isUserAutoPlayNextVideoValid, 'auto play next video boolean'))
@Column
autoPlayNextVideo: boolean
declare autoPlayNextVideo: boolean
@AllowNull(false)
@Default(true)
@ -373,56 +373,56 @@ export class UserModel extends SequelizeModel<UserModel> {
value => throwIfNotValid(value, isUserAutoPlayNextVideoPlaylistValid, 'auto play next video for playlists boolean')
)
@Column
autoPlayNextVideoPlaylist: boolean
declare autoPlayNextVideoPlaylist: boolean
@AllowNull(true)
@Column(DataType.STRING)
language: string
declare language: string
@AllowNull(true)
@Default(null)
@Is('UserVideoLanguages', value => throwIfNotValid(value, isUserVideoLanguages, 'video languages'))
@Column(DataType.ARRAY(DataType.STRING))
videoLanguages: string[]
declare videoLanguages: string[]
@AllowNull(false)
@Default(UserAdminFlag.NONE)
@Is('UserAdminFlags', value => throwIfNotValid(value, isUserAdminFlagsValid, 'user admin flags'))
@Column
adminFlags: UserAdminFlagType
declare adminFlags: UserAdminFlagType
@AllowNull(false)
@Default(false)
@Is('UserBlocked', value => throwIfNotValid(value, isUserBlockedValid, 'blocked boolean'))
@Column
blocked: boolean
declare blocked: boolean
@AllowNull(true)
@Default(null)
@Is('UserBlockedReason', value => throwIfNotValid(value, isUserBlockedReasonValid, 'blocked reason', true))
@Column
blockedReason: string
declare blockedReason: string
@AllowNull(false)
@Is('UserRole', value => throwIfNotValid(value, isUserRoleValid, 'role'))
@Column
role: UserRoleType
declare role: UserRoleType
@AllowNull(false)
@Is('UserVideoQuota', value => throwIfNotValid(value, isUserVideoQuotaValid, 'video quota'))
@Column(DataType.BIGINT)
videoQuota: number
declare videoQuota: number
@AllowNull(false)
@Is('UserVideoQuotaDaily', value => throwIfNotValid(value, isUserVideoQuotaDailyValid, 'video quota daily'))
@Column(DataType.BIGINT)
videoQuotaDaily: number
declare videoQuotaDaily: number
@AllowNull(false)
@Default(DEFAULT_USER_THEME_NAME)
@Is('UserTheme', value => throwIfNotValid(value, isThemeNameValid, 'theme'))
@Column
theme: string
declare theme: string
@AllowNull(false)
@Default(false)
@ -431,7 +431,7 @@ export class UserModel extends SequelizeModel<UserModel> {
value => throwIfNotValid(value, isUserNoModal, 'no instance config warning modal')
)
@Column
noInstanceConfigWarningModal: boolean
declare noInstanceConfigWarningModal: boolean
@AllowNull(false)
@Default(false)
@ -440,7 +440,7 @@ export class UserModel extends SequelizeModel<UserModel> {
value => throwIfNotValid(value, isUserNoModal, 'no welcome modal')
)
@Column
noWelcomeModal: boolean
declare noWelcomeModal: boolean
@AllowNull(false)
@Default(false)
@ -449,72 +449,72 @@ export class UserModel extends SequelizeModel<UserModel> {
value => throwIfNotValid(value, isUserNoModal, 'no account setup warning modal')
)
@Column
noAccountSetupWarningModal: boolean
declare noAccountSetupWarningModal: boolean
@AllowNull(true)
@Default(null)
@Column
pluginAuth: string
declare pluginAuth: string
@AllowNull(false)
@Default(DataType.UUIDV4)
@IsUUID(4)
@Column(DataType.UUID)
feedToken: string
declare feedToken: string
@AllowNull(true)
@Default(null)
@Column
lastLoginDate: Date
declare lastLoginDate: Date
@AllowNull(false)
@Default(false)
@Column
emailPublic: boolean
declare emailPublic: boolean
@AllowNull(true)
@Default(null)
@Column
otpSecret: string
declare otpSecret: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@HasOne(() => AccountModel, {
foreignKey: 'userId',
onDelete: 'cascade',
hooks: true
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
@HasOne(() => UserNotificationSettingModel, {
foreignKey: 'userId',
onDelete: 'cascade',
hooks: true
})
NotificationSetting: Awaited<UserNotificationSettingModel>
declare NotificationSetting: Awaited<UserNotificationSettingModel>
@HasMany(() => VideoImportModel, {
foreignKey: 'userId',
onDelete: 'cascade'
})
VideoImports: Awaited<VideoImportModel>[]
declare VideoImports: Awaited<VideoImportModel>[]
@HasMany(() => OAuthTokenModel, {
foreignKey: 'userId',
onDelete: 'cascade'
})
OAuthTokens: Awaited<OAuthTokenModel>[]
declare OAuthTokens: Awaited<OAuthTokenModel>[]
@HasMany(() => UserExportModel, {
foreignKey: 'userId',
onDelete: 'cascade',
hooks: true
})
UserExports: Awaited<UserExportModel>[]
declare UserExports: Awaited<UserExportModel>[]
// Used if we already set an encrypted password in user model
skipPasswordEncryption = false

View file

@ -18,26 +18,25 @@ import { SequelizeModel } from '../shared/index.js'
]
})
export class ScheduleVideoUpdateModel extends SequelizeModel<ScheduleVideoUpdateModel> {
@AllowNull(false)
@Default(null)
@Column
updateAt: Date
declare updateAt: Date
@AllowNull(true)
@Default(null)
@Column(DataType.INTEGER)
privacy: typeof VideoPrivacy.PUBLIC | typeof VideoPrivacy.UNLISTED | typeof VideoPrivacy.INTERNAL
declare privacy: typeof VideoPrivacy.PUBLIC | typeof VideoPrivacy.UNLISTED | typeof VideoPrivacy.INTERNAL
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -45,7 +44,7 @@ export class ScheduleVideoUpdateModel extends SequelizeModel<ScheduleVideoUpdate
},
onDelete: 'cascade'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static areVideosToUpdate () {
const query = {

View file

@ -13,14 +13,10 @@ export type FileQueryOptions = {
}
/**
*
* Fetch files (web videos and streaming playlist) according to a video
*
*/
export class VideoFileQueryBuilder extends AbstractVideoQueryBuilder {
protected attributes: { [key: string]: string }
constructor (protected readonly sequelize: Sequelize) {
super(sequelize, 'get')
}

View file

@ -6,21 +6,19 @@ import { VideoModelBuilder } from './shared/video-model-builder.js'
import { VideoTableAttributes } from './shared/video-table-attributes.js'
/**
*
* Build a GET SQL query, fetch rows and create the video model
*
*/
export type GetType =
'api' |
'full' |
'account-blacklist-files' |
'account' |
'all-files' |
'thumbnails' |
'thumbnails-blacklist' |
'id' |
'blacklist-rights'
| 'api'
| 'full'
| 'account-blacklist-files'
| 'account'
| 'all-files'
| 'thumbnails'
| 'thumbnails-blacklist'
| 'id'
| 'blacklist-rights'
export type BuildVideoGetQueryOptions = {
id?: number | string
@ -91,8 +89,6 @@ export class VideoModelGetQueryBuilder {
}
export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder {
protected attributes: { [key: string]: string }
protected webVideoFilesQuery: string
protected streamingPlaylistFilesQuery: string

View file

@ -1,20 +1,18 @@
import { Sequelize } from 'sequelize'
import { pick } from '@peertube/peertube-core-utils'
import { VideoInclude } from '@peertube/peertube-models'
import { getServerActor } from '@server/models/application/application.js'
import { MActorAccount } from '@server/types/models/index.js'
import { Sequelize } from 'sequelize'
import { AbstractVideoQueryBuilder } from './shared/abstract-video-query-builder.js'
import { VideoFileQueryBuilder } from './shared/video-file-query-builder.js'
import { VideoModelBuilder } from './shared/video-model-builder.js'
import { BuildVideosListQueryOptions, VideosIdListQueryBuilder } from './videos-id-list-query-builder.js'
import { getServerActor } from '@server/models/application/application.js'
import { MActorAccount } from '@server/types/models/index.js'
/**
* Build videos list SQL query and create video models
*/
export class VideosModelListQueryBuilder extends AbstractVideoQueryBuilder {
protected attributes: { [key: string]: string }
private innerQuery: string
private innerSort: string

View file

@ -24,38 +24,37 @@ import { SequelizeModel } from '../shared/index.js'
]
})
export class StoryboardModel extends SequelizeModel<StoryboardModel> {
@AllowNull(false)
@Column
declare filename: string
@AllowNull(false)
@Column
filename: string
declare totalHeight: number
@AllowNull(false)
@Column
totalHeight: number
declare totalWidth: number
@AllowNull(false)
@Column
totalWidth: number
declare spriteHeight: number
@AllowNull(false)
@Column
spriteHeight: number
declare spriteWidth: number
@AllowNull(false)
@Column
spriteWidth: number
@AllowNull(false)
@Column
spriteDuration: number
declare spriteDuration: number
@AllowNull(true)
@Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))
fileUrl: string
declare fileUrl: string
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -63,13 +62,13 @@ export class StoryboardModel extends SequelizeModel<StoryboardModel> {
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AfterDestroy
static removeInstanceFile (instance: StoryboardModel) {

View file

@ -22,18 +22,17 @@ import { VideoModel } from './video.js'
]
})
export class TagModel extends SequelizeModel<TagModel> {
@AllowNull(false)
@Is('VideoTag', value => throwIfNotValid(value, isVideoTagValid, 'tag'))
@Column
name: string
declare name: string
@BelongsToMany(() => VideoModel, {
foreignKey: 'tagId',
through: () => VideoTagModel,
onDelete: 'CASCADE'
})
Videos: Awaited<VideoModel>[]
declare Videos: Awaited<VideoModel>[]
// threshold corresponds to how many video the field should have to be returned
static getRandomSamples (threshold: number, count: number): Promise<string[]> {

View file

@ -13,7 +13,8 @@ import {
CreatedAt,
DataType,
Default,
ForeignKey, Table,
ForeignKey,
Table,
UpdatedAt
} from 'sequelize-typescript'
import { logger } from '../../helpers/logger.js'
@ -40,40 +41,39 @@ import { SequelizeModel } from '../shared/sequelize-type.js'
]
})
export class ThumbnailModel extends SequelizeModel<ThumbnailModel> {
@AllowNull(false)
@Column
filename: string
declare filename: string
@AllowNull(true)
@Default(null)
@Column
height: number
declare height: number
@AllowNull(true)
@Default(null)
@Column
width: number
declare width: number
@AllowNull(false)
@Column
type: ThumbnailType_Type
declare type: ThumbnailType_Type
@AllowNull(true)
@Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))
fileUrl: string
declare fileUrl: string
@AllowNull(true)
@Column
automaticallyGenerated: boolean
declare automaticallyGenerated: boolean
@AllowNull(false)
@Column
onDisk: boolean
declare onDisk: boolean
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -81,11 +81,11 @@ export class ThumbnailModel extends SequelizeModel<ThumbnailModel> {
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@ForeignKey(() => VideoPlaylistModel)
@Column
videoPlaylistId: number
declare videoPlaylistId: number
@BelongsTo(() => VideoPlaylistModel, {
foreignKey: {
@ -93,13 +93,13 @@ export class ThumbnailModel extends SequelizeModel<ThumbnailModel> {
},
onDelete: 'CASCADE'
})
VideoPlaylist: Awaited<VideoPlaylistModel>
declare VideoPlaylist: Awaited<VideoPlaylistModel>
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
// If this thumbnail replaced existing one, track the old name
previousThumbnailFilename: string

View file

@ -19,31 +19,30 @@ import { VideoModel } from './video.js'
]
})
export class VideoBlacklistModel extends SequelizeModel<VideoBlacklistModel> {
@AllowNull(true)
@Is('VideoBlacklistReason', value => throwIfNotValid(value, isVideoBlacklistReasonValid, 'reason', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_BLACKLIST.REASON.max))
reason: string
declare reason: string
@AllowNull(false)
@Column
unfederated: boolean
declare unfederated: boolean
@AllowNull(false)
@Default(null)
@Is('VideoBlacklistType', value => throwIfNotValid(value, isVideoBlacklistTypeValid, 'type'))
@Column
type: VideoBlacklistType_Type
declare type: VideoBlacklistType_Type
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -51,7 +50,7 @@ export class VideoBlacklistModel extends SequelizeModel<VideoBlacklistModel> {
},
onDelete: 'cascade'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static listForApi (parameters: {
start: number

View file

@ -75,44 +75,44 @@ const videoAttributes = [ 'id', 'name', 'remote', 'uuid', 'url', 'state', 'priva
})
export class VideoCaptionModel extends SequelizeModel<VideoCaptionModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Is('VideoCaptionLanguage', value => throwIfNotValid(value, isVideoCaptionLanguageValid, 'language'))
@Column
language: string
declare language: string
@AllowNull(false)
@Column
filename: string
declare filename: string
@AllowNull(true)
@Column
m3u8Filename: string
declare m3u8Filename: string
@AllowNull(false)
@Default(FileStorage.FILE_SYSTEM)
@Column
storage: FileStorageType
declare storage: FileStorageType
@AllowNull(true)
@Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))
fileUrl: string
declare fileUrl: string
@AllowNull(true)
@Column
m3u8Url: string
declare m3u8Url: string
@AllowNull(false)
@Column
automaticallyGenerated: boolean
declare automaticallyGenerated: boolean
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -120,7 +120,7 @@ export class VideoCaptionModel extends SequelizeModel<VideoCaptionModel> {
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@BeforeDestroy
static async removeFiles (instance: VideoCaptionModel, options) {

View file

@ -55,18 +55,18 @@ enum ScopeNames {
}))
export class VideoChangeOwnershipModel extends SequelizeModel<VideoChangeOwnershipModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Column
status: VideoChangeOwnershipStatusType
declare status: VideoChangeOwnershipStatusType
@ForeignKey(() => AccountModel)
@Column
initiatorAccountId: number
declare initiatorAccountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -75,11 +75,11 @@ export class VideoChangeOwnershipModel extends SequelizeModel<VideoChangeOwnersh
},
onDelete: 'cascade'
})
Initiator: Awaited<AccountModel>
declare Initiator: Awaited<AccountModel>
@ForeignKey(() => AccountModel)
@Column
nextOwnerAccountId: number
declare nextOwnerAccountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -88,11 +88,11 @@ export class VideoChangeOwnershipModel extends SequelizeModel<VideoChangeOwnersh
},
onDelete: 'cascade'
})
NextOwner: Awaited<AccountModel>
declare NextOwner: Awaited<AccountModel>
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -100,7 +100,7 @@ export class VideoChangeOwnershipModel extends SequelizeModel<VideoChangeOwnersh
},
onDelete: 'cascade'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static listForApi (nextOwnerId: number, start: number, count: number, sort: string) {
const query = {

View file

@ -13,7 +13,8 @@ import {
Default,
DefaultScope,
ForeignKey,
Is, Table,
Is,
Table,
UpdatedAt
} from 'sequelize-typescript'
import { AccountModel } from '../account/account.js'
@ -38,32 +39,31 @@ import { VideoChannelModel } from './video-channel.js'
]
})
export class VideoChannelSyncModel extends SequelizeModel<VideoChannelSyncModel> {
@AllowNull(false)
@Default(null)
@Is('VideoChannelExternalChannelUrl', value => throwIfNotValid(value, isUrlValid, 'externalChannelUrl', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNEL_SYNCS.EXTERNAL_CHANNEL_URL.max))
externalChannelUrl: string
declare externalChannelUrl: string
@AllowNull(false)
@Default(VideoChannelSyncState.WAITING_FIRST_RUN)
@Is('VideoChannelSyncState', value => throwIfNotValid(value, isVideoChannelSyncStateValid, 'state'))
@Column
state: VideoChannelSyncStateType
declare state: VideoChannelSyncStateType
@AllowNull(true)
@Column(DataType.DATE)
lastSyncAt: Date
declare lastSyncAt: Date
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoChannelModel)
@Column
videoChannelId: number
declare videoChannelId: number
@BelongsTo(() => VideoChannelModel, {
foreignKey: {
@ -71,7 +71,7 @@ export class VideoChannelSyncModel extends SequelizeModel<VideoChannelSyncModel>
},
onDelete: 'cascade'
})
VideoChannel: Awaited<VideoChannelModel>
declare VideoChannel: Awaited<VideoChannelModel>
static listByAccountForAPI (options: {
accountId: number

View file

@ -357,29 +357,29 @@ export class VideoChannelModel extends SequelizeModel<VideoChannelModel> {
@AllowNull(false)
@Is('VideoChannelName', value => throwIfNotValid(value, isVideoChannelDisplayNameValid, 'name'))
@Column
name: string
declare name: string
@AllowNull(true)
@Default(null)
@Is('VideoChannelDescription', value => throwIfNotValid(value, isVideoChannelDescriptionValid, 'description', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.DESCRIPTION.max))
description: string
declare description: string
@AllowNull(true)
@Default(null)
@Is('VideoChannelSupport', value => throwIfNotValid(value, isVideoChannelSupportValid, 'support', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max))
support: string
declare support: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => ActorModel)
@Column
actorId: number
declare actorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
@ -387,18 +387,18 @@ export class VideoChannelModel extends SequelizeModel<VideoChannelModel> {
},
onDelete: 'cascade'
})
Actor: Awaited<ActorModel>
declare Actor: Awaited<ActorModel>
@ForeignKey(() => AccountModel)
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
allowNull: false
}
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
@HasMany(() => VideoModel, {
foreignKey: {
@ -408,7 +408,7 @@ export class VideoChannelModel extends SequelizeModel<VideoChannelModel> {
onDelete: 'CASCADE',
hooks: true
})
Videos: Awaited<VideoModel>[]
declare Videos: Awaited<VideoModel>[]
@HasMany(() => VideoPlaylistModel, {
foreignKey: {
@ -417,7 +417,7 @@ export class VideoChannelModel extends SequelizeModel<VideoChannelModel> {
onDelete: 'CASCADE',
hooks: true
})
VideoPlaylists: Awaited<VideoPlaylistModel>[]
declare VideoPlaylists: Awaited<VideoPlaylistModel>[]
@AfterCreate
static notifyCreate (channel: MChannel) {

View file

@ -16,18 +16,17 @@ import { SequelizeModel } from '../shared/sequelize-type.js'
]
})
export class VideoChapterModel extends SequelizeModel<VideoChapterModel> {
@AllowNull(false)
@Column
declare timecode: number
@AllowNull(false)
@Column
timecode: number
@AllowNull(false)
@Column
title: string
declare title: string
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -35,13 +34,13 @@ export class VideoChapterModel extends SequelizeModel<VideoChapterModel> {
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
static deleteChapters (videoId: number, transaction: Transaction) {
const query = {

View file

@ -138,35 +138,35 @@ export enum ScopeNames {
})
export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(true)
@Column(DataType.DATE)
deletedAt: Date
declare deletedAt: Date
@AllowNull(false)
@Is('VideoCommentUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.URL.max))
url: string
declare url: string
@AllowNull(false)
@Column(DataType.TEXT)
text: string
declare text: string
@AllowNull(false)
@Column
heldForReview: boolean
declare heldForReview: boolean
@AllowNull(true)
@Column
replyApproval: string
declare replyApproval: string
@ForeignKey(() => VideoCommentModel)
@Column
originCommentId: number
declare originCommentId: number
@BelongsTo(() => VideoCommentModel, {
foreignKey: {
@ -176,11 +176,11 @@ export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {
as: 'OriginVideoComment',
onDelete: 'CASCADE'
})
OriginVideoComment: Awaited<VideoCommentModel>
declare OriginVideoComment: Awaited<VideoCommentModel>
@ForeignKey(() => VideoCommentModel)
@Column
inReplyToCommentId: number
declare inReplyToCommentId: number
@BelongsTo(() => VideoCommentModel, {
foreignKey: {
@ -190,11 +190,11 @@ export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {
as: 'InReplyToVideoComment',
onDelete: 'CASCADE'
})
InReplyToVideoComment: Awaited<VideoCommentModel> | null
declare InReplyToVideoComment: Awaited<VideoCommentModel> | null
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -202,11 +202,11 @@ export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@ForeignKey(() => AccountModel)
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -214,7 +214,7 @@ export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {
},
onDelete: 'CASCADE'
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
@HasMany(() => VideoCommentAbuseModel, {
foreignKey: {
@ -223,13 +223,13 @@ export class VideoCommentModel extends SequelizeModel<VideoCommentModel> {
},
onDelete: 'set null'
})
CommentAbuses: Awaited<VideoCommentAbuseModel>[]
declare CommentAbuses: Awaited<VideoCommentAbuseModel>[]
@HasMany(() => CommentAutomaticTagModel, {
foreignKey: 'commentId',
onDelete: 'CASCADE'
})
CommentAutomaticTags: Awaited<CommentAutomaticTagModel>[]
declare CommentAutomaticTags: Awaited<CommentAutomaticTagModel>[]
@AfterCreate
@AfterDestroy

View file

@ -12,11 +12,7 @@ import { logger } from '@server/helpers/logger.js'
import { extractVideo } from '@server/helpers/video.js'
import { CONFIG } from '@server/initializers/config.js'
import { buildRemoteUrl } from '@server/lib/activitypub/url.js'
import {
getHLSPrivateFileUrl,
getObjectStoragePublicFileUrl,
getWebVideoPrivateFileUrl
} from '@server/lib/object-storage/index.js'
import { getHLSPrivateFileUrl, getObjectStoragePublicFileUrl, getWebVideoPrivateFileUrl } from '@server/lib/object-storage/index.js'
import { getFSTorrentFilePath } from '@server/lib/paths.js'
import { getVideoFileMimeType } from '@server/lib/video-file.js'
import { isVideoInPrivateDirectory } from '@server/lib/video-privacy.js'
@ -34,7 +30,8 @@ import {
Default,
DefaultScope,
ForeignKey,
Is, Scopes,
Is,
Scopes,
Table,
UpdatedAt
} from 'sequelize-typescript'
@ -46,14 +43,7 @@ import {
isVideoFileResolutionValid,
isVideoFileSizeValid
} from '../../helpers/custom-validators/videos.js'
import {
DOWNLOAD_PATHS,
LAZY_STATIC_PATHS,
MEMOIZE_LENGTH,
MEMOIZE_TTL,
STATIC_PATHS,
WEBSERVER
} from '../../initializers/constants.js'
import { DOWNLOAD_PATHS, LAZY_STATIC_PATHS, MEMOIZE_LENGTH, MEMOIZE_TTL, STATIC_PATHS, WEBSERVER } from '../../initializers/constants.js'
import { MVideoFile, MVideoFileStreamingPlaylistVideo, MVideoFileVideo } from '../../types/models/video/video-file.js'
import { SequelizeModel, doesExist, parseAggregateResult, throwIfNotValid } from '../shared/index.js'
import { VideoStreamingPlaylistModel } from './video-streaming-playlist.js'
@ -146,89 +136,89 @@ export enum ScopeNames {
})
export class VideoFileModel extends SequelizeModel<VideoFileModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Is('VideoFileResolution', value => throwIfNotValid(value, isVideoFileResolutionValid, 'resolution'))
@Column
resolution: number
declare resolution: number
@AllowNull(true)
@Column
width: number
declare width: number
@AllowNull(true)
@Column
height: number
declare height: number
@AllowNull(false)
@Is('VideoFileSize', value => throwIfNotValid(value, isVideoFileSizeValid, 'size'))
@Column(DataType.BIGINT)
size: number
declare size: number
@AllowNull(false)
@Is('VideoFileExtname', value => throwIfNotValid(value, isVideoFileExtnameValid, 'extname'))
@Column
extname: string
declare extname: string
@AllowNull(true)
@Is('VideoFileInfohash', value => throwIfNotValid(value, isVideoFileInfoHashValid, 'info hash', true))
@Column
infoHash: string
declare infoHash: string
@AllowNull(false)
@Default(-1)
@Is('VideoFileFPS', value => throwIfNotValid(value, isVideoFPSResolutionValid, 'fps'))
@Column
fps: number
declare fps: number
@AllowNull(false)
@Column
formatFlags: VideoFileFormatFlagType
declare formatFlags: VideoFileFormatFlagType
@AllowNull(false)
@Column
streams: VideoFileStreamType
declare streams: VideoFileStreamType
@AllowNull(true)
@Column(DataType.JSONB)
metadata: any
declare metadata: any
@AllowNull(true)
@Column
metadataUrl: string
declare metadataUrl: string
// Could be null for remote files
@AllowNull(true)
@Column
fileUrl: string
declare fileUrl: string
// Could be null for live files
@AllowNull(true)
@Column
filename: string
declare filename: string
// Could be null for remote files
@AllowNull(true)
@Column
torrentUrl: string
declare torrentUrl: string
// Could be null for live files
@AllowNull(true)
@Column
torrentFilename: string
declare torrentFilename: string
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@AllowNull(false)
@Default(FileStorage.FILE_SYSTEM)
@Column
storage: FileStorageType
declare storage: FileStorageType
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -236,11 +226,11 @@ export class VideoFileModel extends SequelizeModel<VideoFileModel> {
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@ForeignKey(() => VideoStreamingPlaylistModel)
@Column
videoStreamingPlaylistId: number
declare videoStreamingPlaylistId: number
@BelongsTo(() => VideoStreamingPlaylistModel, {
foreignKey: {
@ -248,7 +238,7 @@ export class VideoFileModel extends SequelizeModel<VideoFileModel> {
},
onDelete: 'CASCADE'
})
VideoStreamingPlaylist: Awaited<VideoStreamingPlaylistModel>
declare VideoStreamingPlaylist: Awaited<VideoStreamingPlaylistModel>
static doesInfohashExistCached = memoizee(VideoFileModel.doesInfohashExist.bind(VideoFileModel), {
promise: true,

View file

@ -62,42 +62,42 @@ const defaultVideoScope = () => {
})
export class VideoImportModel extends SequelizeModel<VideoImportModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(true)
@Default(null)
@Is('VideoImportTargetUrl', value => throwIfNotValid(value, isVideoImportTargetUrlValid, 'targetUrl', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL.max))
targetUrl: string
declare targetUrl: string
@AllowNull(true)
@Default(null)
@Is('VideoImportMagnetUri', value => throwIfNotValid(value, isVideoMagnetUriValid, 'magnetUri', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_IMPORTS.URL.max)) // Use the same constraints than URLs
magnetUri: string
declare magnetUri: string
@AllowNull(true)
@Default(null)
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_IMPORTS.TORRENT_NAME.max))
torrentName: string
declare torrentName: string
@AllowNull(false)
@Default(null)
@Is('VideoImportState', value => throwIfNotValid(value, isVideoImportStateValid, 'state'))
@Column
state: VideoImportStateType
declare state: VideoImportStateType
@AllowNull(true)
@Default(null)
@Column(DataType.TEXT)
error: string
declare error: string
@ForeignKey(() => UserModel)
@Column
userId: number
declare userId: number
@BelongsTo(() => UserModel, {
foreignKey: {
@ -105,11 +105,11 @@ export class VideoImportModel extends SequelizeModel<VideoImportModel> {
},
onDelete: 'cascade'
})
User: Awaited<UserModel>
declare User: Awaited<UserModel>
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -117,11 +117,11 @@ export class VideoImportModel extends SequelizeModel<VideoImportModel> {
},
onDelete: 'set null'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@ForeignKey(() => VideoChannelSyncModel)
@Column
videoChannelSyncId: number
declare videoChannelSyncId: number
@BelongsTo(() => VideoChannelSyncModel, {
foreignKey: {
@ -129,7 +129,7 @@ export class VideoImportModel extends SequelizeModel<VideoImportModel> {
},
onDelete: 'set null'
})
VideoChannelSync: Awaited<VideoChannelSyncModel>
declare VideoChannelSync: Awaited<VideoChannelSyncModel>
@AfterUpdate
static deleteVideoIfFailed (instance: VideoImportModel, options) {

View file

@ -21,33 +21,33 @@ export type VideoJobInfoColumnType = 'pendingMove' | 'pendingTranscode' | 'pendi
})
export class VideoJobInfoModel extends SequelizeModel<VideoJobInfoModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Default(0)
@IsInt
@Column
pendingMove: number
declare pendingMove: number
@AllowNull(false)
@Default(0)
@IsInt
@Column
pendingTranscode: number
declare pendingTranscode: number
@AllowNull(false)
@Default(0)
@IsInt
@Column
pendingTranscription: number
declare pendingTranscription: number
@ForeignKey(() => VideoModel)
@Unique
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -55,7 +55,7 @@ export class VideoJobInfoModel extends SequelizeModel<VideoJobInfoModel> {
},
onDelete: 'cascade'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static load (videoId: number, transaction?: Transaction) {
const where = {

View file

@ -10,17 +10,16 @@ import { SequelizeModel } from '../shared/index.js'
tableName: 'videoLiveReplaySetting'
})
export class VideoLiveReplaySettingModel extends SequelizeModel<VideoLiveReplaySettingModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Is('VideoPrivacy', value => throwIfNotValid(value, isVideoPrivacyValid, 'privacy'))
@Column
privacy: VideoPrivacyType
declare privacy: VideoPrivacyType
static load (id: number, transaction?: Transaction): Promise<MLiveReplaySetting> {
return VideoLiveReplaySettingModel.findOne({

View file

@ -56,34 +56,34 @@ export enum ScopeNames {
})
export class VideoLiveSessionModel extends SequelizeModel<VideoLiveSessionModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Column(DataType.DATE)
startDate: Date
declare startDate: Date
@AllowNull(true)
@Column(DataType.DATE)
endDate: Date
declare endDate: Date
@AllowNull(true)
@Column
error: LiveVideoErrorType
declare error: LiveVideoErrorType
@AllowNull(false)
@Column
saveReplay: boolean
declare saveReplay: boolean
@AllowNull(false)
@Column
endingProcessed: boolean
declare endingProcessed: boolean
@ForeignKey(() => VideoModel)
@Column
replayVideoId: number
declare replayVideoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -93,11 +93,11 @@ export class VideoLiveSessionModel extends SequelizeModel<VideoLiveSessionModel>
as: 'ReplayVideo',
onDelete: 'set null'
})
ReplayVideo: Awaited<VideoModel>
declare ReplayVideo: Awaited<VideoModel>
@ForeignKey(() => VideoModel)
@Column
liveVideoId: number
declare liveVideoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -107,11 +107,11 @@ export class VideoLiveSessionModel extends SequelizeModel<VideoLiveSessionModel>
as: 'LiveVideo',
onDelete: 'set null'
})
LiveVideo: Awaited<VideoModel>
declare LiveVideo: Awaited<VideoModel>
@ForeignKey(() => VideoLiveReplaySettingModel)
@Column
replaySettingId: number
declare replaySettingId: number
@BelongsTo(() => VideoLiveReplaySettingModel, {
foreignKey: {
@ -119,7 +119,7 @@ export class VideoLiveSessionModel extends SequelizeModel<VideoLiveSessionModel>
},
onDelete: 'set null'
})
ReplaySetting: Awaited<VideoLiveReplaySettingModel>
declare ReplaySetting: Awaited<VideoLiveReplaySettingModel>
@BeforeDestroy
static deleteReplaySetting (instance: VideoLiveSessionModel) {

View file

@ -11,7 +11,8 @@ import {
CreatedAt,
DataType,
DefaultScope,
ForeignKey, Table,
ForeignKey,
Table,
UpdatedAt
} from 'sequelize-typescript'
import { VideoBlacklistModel } from './video-blacklist.js'
@ -51,32 +52,31 @@ import { SequelizeModel } from '../shared/index.js'
]
})
export class VideoLiveModel extends SequelizeModel<VideoLiveModel> {
@AllowNull(true)
@Column(DataType.STRING)
streamKey: string
declare streamKey: string
@AllowNull(false)
@Column
saveReplay: boolean
declare saveReplay: boolean
@AllowNull(false)
@Column
permanentLive: boolean
declare permanentLive: boolean
@AllowNull(false)
@Column
latencyMode: LiveVideoLatencyModeType
declare latencyMode: LiveVideoLatencyModeType
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -84,11 +84,11 @@ export class VideoLiveModel extends SequelizeModel<VideoLiveModel> {
},
onDelete: 'cascade'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@ForeignKey(() => VideoLiveReplaySettingModel)
@Column
replaySettingId: number
declare replaySettingId: number
@BelongsTo(() => VideoLiveReplaySettingModel, {
foreignKey: {
@ -96,7 +96,7 @@ export class VideoLiveModel extends SequelizeModel<VideoLiveModel> {
},
onDelete: 'set null'
})
ReplaySetting: Awaited<VideoLiveReplaySettingModel>
declare ReplaySetting: Awaited<VideoLiveReplaySettingModel>
@BeforeDestroy
static deleteReplaySetting (instance: VideoLiveModel, options: { transaction: Transaction }) {

View file

@ -25,21 +25,20 @@ import { pick } from '@peertube/peertube-core-utils'
]
})
export class VideoPasswordModel extends SequelizeModel<VideoPasswordModel> {
@AllowNull(false)
@Is('VideoPassword', value => throwIfNotValid(value, isPasswordValid, 'videoPassword'))
@Column
password: string
declare password: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -47,7 +46,7 @@ export class VideoPasswordModel extends SequelizeModel<VideoPasswordModel> {
},
onDelete: 'cascade'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static async countByVideoId (videoId: number, t?: Transaction) {
const query = {

View file

@ -55,38 +55,38 @@ import { ForAPIOptions, VideoModel, ScopeNames as VideoScopeNames } from './vide
})
export class VideoPlaylistElementModel extends SequelizeModel<VideoPlaylistElementModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(true)
@Is('VideoPlaylistUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.URL.max))
url: string
declare url: string
@AllowNull(false)
@Default(1)
@IsInt
@Min(1)
@Column
position: number
declare position: number
@AllowNull(true)
@IsInt
@Min(0)
@Column
startTimestamp: number
declare startTimestamp: number
@AllowNull(true)
@IsInt
@Min(0)
@Column
stopTimestamp: number
declare stopTimestamp: number
@ForeignKey(() => VideoPlaylistModel)
@Column
videoPlaylistId: number
declare videoPlaylistId: number
@BelongsTo(() => VideoPlaylistModel, {
foreignKey: {
@ -94,11 +94,11 @@ export class VideoPlaylistElementModel extends SequelizeModel<VideoPlaylistEleme
},
onDelete: 'CASCADE'
})
VideoPlaylist: Awaited<VideoPlaylistModel>
declare VideoPlaylist: Awaited<VideoPlaylistModel>
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -106,7 +106,7 @@ export class VideoPlaylistElementModel extends SequelizeModel<VideoPlaylistEleme
},
onDelete: 'set null'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static deleteAllOf (videoPlaylistId: number, transaction?: Transaction) {
const query = {

View file

@ -291,49 +291,49 @@ function getVideoLengthSelect () {
})
export class VideoPlaylistModel extends SequelizeModel<VideoPlaylistModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Is('VideoPlaylistName', value => throwIfNotValid(value, isVideoPlaylistNameValid, 'name'))
@Column
name: string
declare name: string
@AllowNull(true)
@Is('VideoPlaylistDescription', value => throwIfNotValid(value, isVideoPlaylistDescriptionValid, 'description', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.DESCRIPTION.max))
description: string
declare description: string
@AllowNull(false)
@Is('VideoPlaylistPrivacy', value => throwIfNotValid(value, isVideoPlaylistPrivacyValid, 'privacy'))
@Column
privacy: VideoPlaylistPrivacyType
declare privacy: VideoPlaylistPrivacyType
@AllowNull(false)
@Is('VideoPlaylistUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.URL.max))
url: string
declare url: string
@AllowNull(false)
@Default(DataType.UUIDV4)
@IsUUID(4)
@Column(DataType.UUID)
uuid: string
declare uuid: string
@AllowNull(false)
@Default(VideoPlaylistType.REGULAR)
@Column
type: VideoPlaylistType_Type
declare type: VideoPlaylistType_Type
@AllowNull(true)
@Column
videoChannelPosition: number
declare videoChannelPosition: number
@ForeignKey(() => AccountModel)
@Column
ownerAccountId: number
declare ownerAccountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -341,11 +341,11 @@ export class VideoPlaylistModel extends SequelizeModel<VideoPlaylistModel> {
},
onDelete: 'CASCADE'
})
OwnerAccount: Awaited<AccountModel>
declare OwnerAccount: Awaited<AccountModel>
@ForeignKey(() => VideoChannelModel)
@Column
videoChannelId: number
declare videoChannelId: number
@BelongsTo(() => VideoChannelModel, {
foreignKey: {
@ -353,7 +353,7 @@ export class VideoPlaylistModel extends SequelizeModel<VideoPlaylistModel> {
},
onDelete: 'CASCADE'
})
VideoChannel: Awaited<VideoChannelModel>
declare VideoChannel: Awaited<VideoChannelModel>
@HasMany(() => VideoPlaylistElementModel, {
foreignKey: {
@ -362,7 +362,7 @@ export class VideoPlaylistModel extends SequelizeModel<VideoPlaylistModel> {
},
onDelete: 'CASCADE'
})
VideoPlaylistElements: Awaited<VideoPlaylistElementModel>[]
declare VideoPlaylistElements: Awaited<VideoPlaylistElementModel>[]
@HasOne(() => ThumbnailModel, {
foreignKey: {
@ -372,7 +372,7 @@ export class VideoPlaylistModel extends SequelizeModel<VideoPlaylistModel> {
onDelete: 'CASCADE',
hooks: true
})
Thumbnail: Awaited<ThumbnailModel>
declare Thumbnail: Awaited<ThumbnailModel>
static listForApi (
options: AvailableForListOptions & {

View file

@ -52,21 +52,20 @@ enum ScopeNames {
]
})
export class VideoShareModel extends SequelizeModel<VideoShareModel> {
@AllowNull(false)
@Is('VideoShareUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEO_SHARE.URL.max))
url: string
declare url: string
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => ActorModel)
@Column
actorId: number
declare actorId: number
@BelongsTo(() => ActorModel, {
foreignKey: {
@ -74,11 +73,11 @@ export class VideoShareModel extends SequelizeModel<VideoShareModel> {
},
onDelete: 'cascade'
})
Actor: Awaited<ActorModel>
declare Actor: Awaited<ActorModel>
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -86,7 +85,7 @@ export class VideoShareModel extends SequelizeModel<VideoShareModel> {
},
onDelete: 'cascade'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static load (actorId: number | string, videoId: number | string, t?: Transaction): Promise<MVideoShareActor> {
return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({

View file

@ -26,54 +26,54 @@ import { VideoModel } from './video.js'
})
export class VideoSourceModel extends SequelizeModel<VideoSourceModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Column
inputFilename: string
declare inputFilename: string
@AllowNull(true)
@Column
keptOriginalFilename: string
declare keptOriginalFilename: string
@AllowNull(true)
@Column
resolution: number
declare resolution: number
@AllowNull(true)
@Column
width: number
declare width: number
@AllowNull(true)
@Column
height: number
declare height: number
@AllowNull(true)
@Column
fps: number
declare fps: number
@AllowNull(true)
@Column(DataType.BIGINT)
size: number
declare size: number
@AllowNull(true)
@Column(DataType.JSONB)
metadata: any
declare metadata: any
@AllowNull(true)
@Column
storage: FileStorageType
declare storage: FileStorageType
@AllowNull(true)
@Column
fileUrl: string
declare fileUrl: string
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -81,7 +81,7 @@ export class VideoSourceModel extends SequelizeModel<VideoSourceModel> {
},
onDelete: 'cascade'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static loadLatest (videoId: number, transaction?: Transaction) {
return VideoSourceModel.findOne<MVideoSource>({

View file

@ -56,48 +56,48 @@ import { VideoModel } from './video.js'
})
export class VideoStreamingPlaylistModel extends SequelizeModel<VideoStreamingPlaylistModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Column
type: VideoStreamingPlaylistType_Type
declare type: VideoStreamingPlaylistType_Type
@AllowNull(false)
@Column
playlistFilename: string
declare playlistFilename: string
@AllowNull(true)
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.URL.max))
playlistUrl: string
declare playlistUrl: string
@AllowNull(false)
@Is('VideoStreamingPlaylistInfoHashes', value => throwIfNotValid(value, v => isArrayOf(v, isVideoFileInfoHashValid), 'info hashes'))
@Column(DataType.ARRAY(DataType.STRING))
p2pMediaLoaderInfohashes: string[]
declare p2pMediaLoaderInfohashes: string[]
@AllowNull(false)
@Column
p2pMediaLoaderPeerVersion: number
declare p2pMediaLoaderPeerVersion: number
@AllowNull(true)
@Column
segmentsSha256Filename: string
declare segmentsSha256Filename: string
@AllowNull(true)
@Column
segmentsSha256Url: string
declare segmentsSha256Url: string
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@AllowNull(false)
@Default(FileStorage.FILE_SYSTEM)
@Column
storage: FileStorageType
declare storage: FileStorageType
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -105,7 +105,7 @@ export class VideoStreamingPlaylistModel extends SequelizeModel<VideoStreamingPl
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@HasMany(() => VideoFileModel, {
foreignKey: {
@ -113,7 +113,7 @@ export class VideoStreamingPlaylistModel extends SequelizeModel<VideoStreamingPl
},
onDelete: 'CASCADE'
})
VideoFiles: Awaited<VideoFileModel>[]
declare VideoFiles: Awaited<VideoFileModel>[]
@HasMany(() => VideoRedundancyModel, {
foreignKey: {
@ -122,7 +122,7 @@ export class VideoStreamingPlaylistModel extends SequelizeModel<VideoStreamingPl
onDelete: 'CASCADE',
hooks: true
})
RedundancyVideos: Awaited<VideoRedundancyModel>[]
declare RedundancyVideos: Awaited<VideoRedundancyModel>[]
static doesInfohashExistCached = memoizee(VideoStreamingPlaylistModel.doesInfohashExist.bind(VideoStreamingPlaylistModel), {
promise: true,

View file

@ -16,16 +16,16 @@ import { SequelizeModel } from '../shared/index.js'
})
export class VideoTagModel extends SequelizeModel<VideoTagModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@ForeignKey(() => TagModel)
@Column
tagId: number
declare tagId: number
}

View file

@ -439,156 +439,156 @@ export class VideoModel extends SequelizeModel<VideoModel> {
@Default(DataType.UUIDV4)
@IsUUID(4)
@Column(DataType.UUID)
uuid: string
declare uuid: string
@AllowNull(false)
@Is('VideoName', value => throwIfNotValid(value, isVideoNameValid, 'name'))
@Column
name: string
declare name: string
@AllowNull(true)
@Default(null)
@Column
category: number
declare category: number
@AllowNull(true)
@Default(null)
@Column
licence: number
declare licence: number
@AllowNull(true)
@Default(null)
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.LANGUAGE.max))
language: string
declare language: string
@AllowNull(false)
@Is('VideoPrivacy', value => throwIfNotValid(value, isVideoPrivacyValid, 'privacy'))
@Column(DataType.INTEGER)
privacy: VideoPrivacyType
declare privacy: VideoPrivacyType
@AllowNull(false)
@Is('VideoNSFW', value => throwIfNotValid(value, isBooleanValid, 'NSFW boolean'))
@Column
nsfw: boolean
declare nsfw: boolean
@AllowNull(false)
@Default(0)
@Is('VideoNSFWFlags', value => throwIfNotValid(value, isNSFWFlagsValid, 'NSFW flags'))
@Column
nsfwFlags: number // NSFWFlagType
declare nsfwFlags: number // NSFWFlagType
@AllowNull(true)
@Default(null)
@Is('VideoNSFWSummary', value => throwIfNotValid(value, isNSFWSummaryValid, 'NSFW summary'))
@Column
nsfwSummary: string
declare nsfwSummary: string
@AllowNull(true)
@Default(null)
@Is('VideoDescription', value => throwIfNotValid(value, isVideoDescriptionValid, 'description', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max))
description: string
declare description: string
@AllowNull(true)
@Default(null)
@Is('VideoSupport', value => throwIfNotValid(value, isVideoSupportValid, 'support', true))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.SUPPORT.max))
support: string
declare support: string
@AllowNull(false)
@Is('VideoDuration', value => throwIfNotValid(value, isVideoDurationValid, 'duration'))
@Column
duration: number
declare duration: number
@AllowNull(false)
@Default(0)
@IsInt
@Min(0)
@Column
views: number
declare views: number
@AllowNull(false)
@Default(0)
@IsInt
@Min(0)
@Column
likes: number
declare likes: number
@AllowNull(false)
@Default(0)
@IsInt
@Min(0)
@Column
dislikes: number
declare dislikes: number
@AllowNull(false)
@Default(0)
@IsInt
@Min(0)
@Column
comments: number
declare comments: number
@AllowNull(false)
@Column
remote: boolean
declare remote: boolean
@AllowNull(false)
@Default(false)
@Column
isLive: boolean
declare isLive: boolean
@AllowNull(false)
@Is('VideoUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'url'))
@Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.URL.max))
url: string
declare url: string
@AllowNull(false)
@Column
commentsPolicy: VideoCommentPolicyType
declare commentsPolicy: VideoCommentPolicyType
@AllowNull(false)
@Column
downloadEnabled: boolean
declare downloadEnabled: boolean
@AllowNull(false)
@Column
waitTranscoding: boolean
declare waitTranscoding: boolean
@AllowNull(false)
@Default(null)
@Is('VideoState', value => throwIfNotValid(value, isVideoStateValid, 'state'))
@Column
state: VideoStateType
declare state: VideoStateType
@AllowNull(true)
@Column(DataType.FLOAT)
aspectRatio: number
declare aspectRatio: number
// We already have the information in videoSource table for local videos, but we prefer to normalize it for performance
// And also to store the info from remote instances
@AllowNull(true)
@Column
inputFileUpdatedAt: Date
declare inputFileUpdatedAt: Date
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Default(DataType.NOW)
@Column
publishedAt: Date
declare publishedAt: Date
@AllowNull(true)
@Default(null)
@Column
originallyPublishedAt: Date
declare originallyPublishedAt: Date
@ForeignKey(() => VideoChannelModel)
@Column
channelId: number
declare channelId: number
@BelongsTo(() => VideoChannelModel, {
foreignKey: {
@ -596,21 +596,21 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
VideoChannel: Awaited<VideoChannelModel>
declare VideoChannel: Awaited<VideoChannelModel>
@BelongsToMany(() => TagModel, {
foreignKey: 'videoId',
through: () => VideoTagModel,
onDelete: 'CASCADE'
})
Tags: Awaited<TagModel>[]
declare Tags: Awaited<TagModel>[]
@BelongsToMany(() => TrackerModel, {
foreignKey: 'videoId',
through: () => VideoTrackerModel,
onDelete: 'CASCADE'
})
Trackers: Awaited<TrackerModel>[]
declare Trackers: Awaited<TrackerModel>[]
@HasMany(() => ThumbnailModel, {
foreignKey: {
@ -620,7 +620,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
hooks: true,
onDelete: 'cascade'
})
Thumbnails: Awaited<ThumbnailModel>[]
declare Thumbnails: Awaited<ThumbnailModel>[]
@HasMany(() => VideoPlaylistElementModel, {
foreignKey: {
@ -629,7 +629,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'set null'
})
VideoPlaylistElements: Awaited<VideoPlaylistElementModel>[]
declare VideoPlaylistElements: Awaited<VideoPlaylistElementModel>[]
@HasOne(() => VideoSourceModel, {
foreignKey: {
@ -638,7 +638,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'CASCADE'
})
VideoSource: Awaited<VideoSourceModel>
declare VideoSource: Awaited<VideoSourceModel>
@HasMany(() => VideoAbuseModel, {
foreignKey: {
@ -647,7 +647,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'set null'
})
VideoAbuses: Awaited<VideoAbuseModel>[]
declare VideoAbuses: Awaited<VideoAbuseModel>[]
@HasMany(() => VideoFileModel, {
foreignKey: {
@ -656,7 +656,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
VideoFiles: Awaited<VideoFileModel>[]
declare VideoFiles: Awaited<VideoFileModel>[]
@HasMany(() => VideoStreamingPlaylistModel, {
foreignKey: {
@ -665,7 +665,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
VideoStreamingPlaylists: Awaited<VideoStreamingPlaylistModel>[]
declare VideoStreamingPlaylists: Awaited<VideoStreamingPlaylistModel>[]
@HasMany(() => VideoShareModel, {
foreignKey: {
@ -674,7 +674,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
VideoShares: Awaited<VideoShareModel>[]
declare VideoShares: Awaited<VideoShareModel>[]
@HasMany(() => AccountVideoRateModel, {
foreignKey: {
@ -683,7 +683,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
AccountVideoRates: Awaited<AccountVideoRateModel>[]
declare AccountVideoRates: Awaited<AccountVideoRateModel>[]
@HasMany(() => VideoCommentModel, {
foreignKey: {
@ -693,7 +693,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
onDelete: 'cascade',
hooks: true
})
VideoComments: Awaited<VideoCommentModel>[]
declare VideoComments: Awaited<VideoCommentModel>[]
@HasMany(() => VideoViewModel, {
foreignKey: {
@ -702,7 +702,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
VideoViews: Awaited<VideoViewModel>[]
declare VideoViews: Awaited<VideoViewModel>[]
@HasMany(() => UserVideoHistoryModel, {
foreignKey: {
@ -711,7 +711,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
UserVideoHistories: Awaited<UserVideoHistoryModel>[]
declare UserVideoHistories: Awaited<UserVideoHistoryModel>[]
@HasOne(() => ScheduleVideoUpdateModel, {
foreignKey: {
@ -720,7 +720,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
ScheduleVideoUpdate: Awaited<ScheduleVideoUpdateModel>
declare ScheduleVideoUpdate: Awaited<ScheduleVideoUpdateModel>
@HasOne(() => VideoBlacklistModel, {
foreignKey: {
@ -729,7 +729,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
VideoBlacklist: Awaited<VideoBlacklistModel>
declare VideoBlacklist: Awaited<VideoBlacklistModel>
@HasOne(() => VideoLiveModel, {
foreignKey: {
@ -739,7 +739,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
hooks: true,
onDelete: 'cascade'
})
VideoLive: Awaited<VideoLiveModel>
declare VideoLive: Awaited<VideoLiveModel>
@HasOne(() => VideoImportModel, {
foreignKey: {
@ -748,7 +748,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'set null'
})
VideoImport: Awaited<VideoImportModel>
declare VideoImport: Awaited<VideoImportModel>
@HasMany(() => VideoCaptionModel, {
foreignKey: {
@ -759,7 +759,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
hooks: true,
['separate' as any]: true
})
VideoCaptions: Awaited<VideoCaptionModel>[]
declare VideoCaptions: Awaited<VideoCaptionModel>[]
@HasMany(() => VideoPasswordModel, {
foreignKey: {
@ -768,13 +768,13 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
VideoPasswords: Awaited<VideoPasswordModel>[]
declare VideoPasswords: Awaited<VideoPasswordModel>[]
@HasMany(() => VideoAutomaticTagModel, {
foreignKey: 'videoId',
onDelete: 'CASCADE'
})
VideoAutomaticTags: Awaited<VideoAutomaticTagModel>[]
declare VideoAutomaticTags: Awaited<VideoAutomaticTagModel>[]
@HasOne(() => VideoJobInfoModel, {
foreignKey: {
@ -783,7 +783,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
},
onDelete: 'cascade'
})
VideoJobInfo: Awaited<VideoJobInfoModel>
declare VideoJobInfo: Awaited<VideoJobInfoModel>
@HasOne(() => StoryboardModel, {
foreignKey: {
@ -793,7 +793,7 @@ export class VideoModel extends SequelizeModel<VideoModel> {
onDelete: 'cascade',
hooks: true
})
Storyboard: Awaited<StoryboardModel>
declare Storyboard: Awaited<StoryboardModel>
@AfterCreate
static notifyCreate (video: MVideo) {

View file

@ -15,19 +15,19 @@ import { LocalVideoViewerModel } from './local-video-viewer.js'
})
export class LocalVideoViewerWatchSectionModel extends SequelizeModel<LocalVideoViewerWatchSectionModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@AllowNull(false)
@Column
watchStart: number
declare watchStart: number
@AllowNull(false)
@Column
watchEnd: number
declare watchEnd: number
@ForeignKey(() => LocalVideoViewerModel)
@Column
localVideoViewerId: number
declare localVideoViewerId: number
@BelongsTo(() => LocalVideoViewerModel, {
foreignKey: {
@ -35,7 +35,7 @@ export class LocalVideoViewerWatchSectionModel extends SequelizeModel<LocalVideo
},
onDelete: 'CASCADE'
})
LocalVideoViewer: Awaited<LocalVideoViewerModel>
declare LocalVideoViewer: Awaited<LocalVideoViewerModel>
static async bulkCreateSections (options: {
localVideoViewerId: number

View file

@ -35,53 +35,53 @@ import { LocalVideoViewerWatchSectionModel } from './local-video-viewer-watch-se
})
export class LocalVideoViewerModel extends SequelizeModel<LocalVideoViewerModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@AllowNull(false)
@Column(DataType.DATE)
startDate: Date
declare startDate: Date
@AllowNull(false)
@Column(DataType.DATE)
endDate: Date
declare endDate: Date
@AllowNull(false)
@Column
watchTime: number
declare watchTime: number
@AllowNull(true)
@Column
client: string
declare client: string
@AllowNull(true)
@Column
device: string
declare device: string
@AllowNull(true)
@Column
operatingSystem: string
declare operatingSystem: string
@AllowNull(true)
@Column
country: string
declare country: string
@AllowNull(true)
@Column
subdivisionName: string
declare subdivisionName: string
@AllowNull(false)
@Default(DataType.UUIDV4)
@IsUUID(4)
@Column(DataType.UUID)
uuid: string
declare uuid: string
@AllowNull(false)
@Column
url: string
declare url: string
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -89,7 +89,7 @@ export class LocalVideoViewerModel extends SequelizeModel<LocalVideoViewerModel>
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
@HasMany(() => LocalVideoViewerWatchSectionModel, {
foreignKey: {
@ -97,7 +97,7 @@ export class LocalVideoViewerModel extends SequelizeModel<LocalVideoViewerModel>
},
onDelete: 'cascade'
})
WatchSections: Awaited<LocalVideoViewerWatchSectionModel>[]
declare WatchSections: Awaited<LocalVideoViewerWatchSectionModel>[]
static loadByUrl (url: string): Promise<MLocalVideoViewer> {
return this.findOne({

View file

@ -4,10 +4,8 @@ import { VideoModel } from '../video/video.js'
import { SequelizeModel } from '../shared/index.js'
/**
*
* Aggregate views of all videos federated with our instance
* Mainly used by the trending/hot algorithms
*
*/
@Table({
@ -24,23 +22,23 @@ import { SequelizeModel } from '../shared/index.js'
})
export class VideoViewModel extends SequelizeModel<VideoViewModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@AllowNull(false)
@Column(DataType.DATE)
startDate: Date
declare startDate: Date
@AllowNull(false)
@Column(DataType.DATE)
endDate: Date
declare endDate: Date
@AllowNull(false)
@Column
views: number
declare views: number
@ForeignKey(() => VideoModel)
@Column
videoId: number
declare videoId: number
@BelongsTo(() => VideoModel, {
foreignKey: {
@ -48,7 +46,7 @@ export class VideoViewModel extends SequelizeModel<VideoViewModel> {
},
onDelete: 'CASCADE'
})
Video: Awaited<VideoModel>
declare Video: Awaited<VideoModel>
static removeOldRemoteViewsHistory (beforeDate: string) {
const query = {

View file

@ -4,14 +4,7 @@ import { wordsToRegExp } from '@server/helpers/regexp.js'
import { MAccountId, MWatchedWordsList } from '@server/types/models/index.js'
import { LRUCache } from 'lru-cache'
import { Transaction } from 'sequelize'
import {
AllowNull,
BelongsTo,
Column,
CreatedAt,
DataType, ForeignKey, Table,
UpdatedAt
} from 'sequelize-typescript'
import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Table, UpdatedAt } from 'sequelize-typescript'
import { LRU_CACHE, USER_EXPORT_MAX_ITEMS } from '../../initializers/constants.js'
import { AccountModel } from '../account/account.js'
import { SequelizeModel, getSort } from '../shared/index.js'
@ -30,22 +23,22 @@ import { SequelizeModel, getSort } from '../shared/index.js'
})
export class WatchedWordsListModel extends SequelizeModel<WatchedWordsListModel> {
@CreatedAt
createdAt: Date
declare createdAt: Date
@UpdatedAt
updatedAt: Date
declare updatedAt: Date
@AllowNull(false)
@Column
listName: string
declare listName: string
@AllowNull(false)
@Column(DataType.ARRAY(DataType.STRING))
words: string[]
declare words: string[]
@ForeignKey(() => AccountModel)
@Column
accountId: number
declare accountId: number
@BelongsTo(() => AccountModel, {
foreignKey: {
@ -53,7 +46,7 @@ export class WatchedWordsListModel extends SequelizeModel<WatchedWordsListModel>
},
onDelete: 'CASCADE'
})
Account: Awaited<AccountModel>
declare Account: Awaited<AccountModel>
// accountId => reg expressions
private static readonly regexCache = new LRUCache<number, { listName: string, regex: RegExp }[]>({

View file

@ -1,4 +1,11 @@
import { HttpMethodType, PeerTubeProblemDocumentData, ServerErrorCodeType, ServerLogLevel, VideoCreate } from '@peertube/peertube-models'
import {
HttpMethodType,
HttpStatusCodeType,
PeerTubeProblemDocumentData,
ServerErrorCodeType,
ServerLogLevel,
VideoCreate
} from '@peertube/peertube-models'
import { RegisterServerAuthExternalOptions } from '@server/types/index.js'
import {
MAbuseMessage,
@ -107,7 +114,7 @@ declare module 'express' {
message: string
title?: string
status?: number
status?: HttpStatusCodeType
type?: ServerErrorCodeType
instance?: string

View file

@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "NodeNext",
"target": "ES2017",
"target": "ES2022",
"noImplicitAny": false,
"sourceMap": true,
"experimentalDecorators": true,
@ -17,7 +17,10 @@
"es2016",
"es2017",
"es2018",
"es2019"
"es2019",
"es2020",
"es2021",
"es2022"
],
"resolveJsonModule": true,
"strict": false,