1
0
Fork 0

Cleanup model types

This commit is contained in:
Chocobozzz 2019-08-20 13:52:49 +02:00
parent 96ca24f00e
commit 0283eaac2a
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
50 changed files with 696 additions and 349 deletions

View File

@ -19,7 +19,7 @@ import { getOrCreateActorAndServerAndModel, getOrCreateVideoAndAccountAndChannel
import { logger } from '../../helpers/logger'
import { VideoChannelModel } from '../../models/video/video-channel'
import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger'
import { MChannelAccountDefault, MVideoAccountAllFiles } from '../../typings/models'
import { MChannelAccountDefault, MVideoAccountLightBlacklistAllFiles } from '../../typings/models'
const searchRouter = express.Router()
@ -138,7 +138,7 @@ async function searchVideosDB (query: VideosSearchQuery, res: express.Response)
}
async function searchVideoURI (url: string, res: express.Response) {
let video: MVideoAccountAllFiles
let video: MVideoAccountLightBlacklistAllFiles
// Check if we can fetch a remote video with the URL
if (isUserAbleToSearchRemoteURI(res)) {

View File

@ -25,7 +25,7 @@ import { sequelizeTypescript } from '../../../initializers/database'
import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail'
import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
import {
MChannelActorAccountDefault,
MChannelAccountDefault,
MThumbnail,
MUser,
MVideoTag,
@ -234,7 +234,7 @@ function insertIntoDB (parameters: {
video: MVideoThumbnailAccountDefault,
thumbnailModel: MThumbnail,
previewModel: MThumbnail,
videoChannel: MChannelActorAccountDefault,
videoChannel: MChannelAccountDefault,
tags: string[],
videoImportAttributes: Partial<MVideoImport>,
user: MUser

View File

@ -1,6 +1,6 @@
import * as express from 'express'
import { VideoChannelModel } from '../../models/video/video-channel'
import { MChannelActorAccountDefault } from '../../typings/models'
import { MChannelAccountDefault } from '@server/typings/models'
async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
@ -28,7 +28,7 @@ export {
doesVideoChannelNameWithHostExist
}
function processVideoChannelExist (videoChannel: MChannelActorAccountDefault, res: express.Response) {
function processVideoChannelExist (videoChannel: MChannelAccountDefault, res: express.Response) {
if (!videoChannel) {
res.status(404)
.json({ error: 'Video channel not found' })

View File

@ -2,7 +2,7 @@ import { Response } from 'express'
import { fetchVideo, VideoFetchType } from '../video'
import { UserRight } from '../../../shared/models/users'
import { VideoChannelModel } from '../../models/video/video-channel'
import { MUser, MUserAccountId, MVideoAccountLight, MVideoFullLight, MVideoWithRights } from '@server/typings/models'
import { MUser, MUserAccountId, MVideoAccountLight, MVideoFullLight, MVideoThumbnail, MVideoWithRights } from '@server/typings/models'
async function doesVideoExist (id: number | string, res: Response, fetchType: VideoFetchType = 'all') {
const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined
@ -27,7 +27,7 @@ async function doesVideoExist (id: number | string, res: Response, fetchType: Vi
break
case 'only-video':
res.locals.onlyVideo = video
res.locals.onlyVideo = video as MVideoThumbnail
break
case 'only-video-with-rights':

View File

@ -1,6 +1,12 @@
import { VideoModel } from '../models/video/video'
import * as Bluebird from 'bluebird'
import { MVideoAccountAllFiles, MVideoFullLight, MVideoThumbnail, MVideoWithRights, MVideoIdThumbnail } from '@server/typings/models'
import {
MVideoAccountLightBlacklistAllFiles,
MVideoFullLight,
MVideoIdThumbnail,
MVideoThumbnail,
MVideoWithRights
} from '@server/typings/models'
import { Response } from 'express'
type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none'
@ -30,10 +36,10 @@ function fetchVideo (
type VideoFetchByUrlType = 'all' | 'only-video'
function fetchVideoByUrl (url: string, fetchType: 'all'): Bluebird<MVideoAccountAllFiles>
function fetchVideoByUrl (url: string, fetchType: 'all'): Bluebird<MVideoAccountLightBlacklistAllFiles>
function fetchVideoByUrl (url: string, fetchType: 'only-video'): Bluebird<MVideoThumbnail>
function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird<MVideoAccountAllFiles> | Bluebird<MVideoThumbnail>
function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird<MVideoAccountAllFiles> | Bluebird<MVideoThumbnail> {
function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail>
function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail> {
if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url)
if (fetchType === 'only-video') return VideoModel.loadByUrl(url)
@ -43,10 +49,15 @@ function getVideo (res: Response) {
return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights || res.locals.videoId
}
function getVideoWithAttributes (res: Response) {
return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights
}
export {
VideoFetchType,
VideoFetchByUrlType,
fetchVideo,
getVideo,
getVideoWithAttributes,
fetchVideoByUrl
}

View File

@ -24,15 +24,17 @@ import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor'
import { sequelizeTypescript } from '../../initializers/database'
import {
MAccount,
MAccountDefault,
MActor,
MActorAccountChannelId,
MActorAccountChannelIdActor,
MActorAccountId,
MActorDefault,
MActorFull,
MActorFullActor,
MActorId,
MActorAccountChannelIdActor,
MChannel,
MActorFullActor, MAccountActorDefault, MChannelActorDefault, MChannelActorAccountDefault
MChannelAccountDefault
} from '../../typings/models'
// Set account keys, this could be long so process after the account creation and do not block the client
@ -374,12 +376,11 @@ function saveActorAndServerAndModelIfNotExist (
})
if (actorCreated.type === 'Person' || actorCreated.type === 'Application') {
actorCreated.Account = await saveAccount(actorCreated, result, t) as MAccountActorDefault
actorCreated.Account = await saveAccount(actorCreated, result, t) as MAccountDefault
actorCreated.Account.Actor = actorCreated
} else if (actorCreated.type === 'Group') { // Video channel
actorCreated.VideoChannel = await saveVideoChannel(actorCreated, result, ownerActor, t) as MChannelActorAccountDefault
actorCreated.VideoChannel.Actor = actorCreated
actorCreated.VideoChannel.Account = ownerActor.Account
const channel = await saveVideoChannel(actorCreated, result, ownerActor, t)
actorCreated.VideoChannel = Object.assign(channel, { Actor: actorCreated, Account: ownerActor.Account })
}
actorCreated.Server = server

View File

@ -7,7 +7,7 @@ import { getOrCreateVideoAndAccountAndChannel } from '../videos'
import { Notifier } from '../../notifier'
import { logger } from '../../../helpers/logger'
import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
import { MActorSignature, MVideoAccountAllFiles } from '../../../typings/models'
import { MActorSignature, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models'
async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) {
const { activity, byActor: actorAnnouncer } = options
@ -28,7 +28,7 @@ export {
async function processVideoShare (actorAnnouncer: MActorSignature, activity: ActivityAnnounce, notify: boolean) {
const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id
let video: MVideoAccountAllFiles
let video: MVideoAccountLightBlacklistAllFiles
let videoCreated: boolean
try {

View File

@ -11,7 +11,7 @@ import { Notifier } from '../../notifier'
import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
import { createOrUpdateVideoPlaylist } from '../playlist'
import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
import { MActorSignature, MCommentOwnerVideo, MVideoAccountAllFiles } from '../../../typings/models'
import { MActorSignature, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models'
async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) {
const { activity, byActor } = options
@ -81,7 +81,7 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: MAc
if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url)
let video: MVideoAccountAllFiles
let video: MVideoAccountLightBlacklistAllFiles
let created: boolean
let comment: MCommentOwnerVideo
try {

View File

@ -7,7 +7,7 @@ import { getOrCreateActorAndServerAndModel } from './actor'
import { getOrCreateVideoAndAccountAndChannel } from './videos'
import * as Bluebird from 'bluebird'
import { checkUrlsSameHost } from '../../helpers/activitypub'
import { MCommentOwner, MCommentOwnerVideo, MVideoAccountAllFiles } from '../../typings/models/video'
import { MCommentOwner, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../typings/models/video'
type ResolveThreadParams = {
url: string,
@ -15,7 +15,7 @@ type ResolveThreadParams = {
isVideo?: boolean,
commentCreated?: boolean
}
type ResolveThreadResult = Promise<{ video: MVideoAccountAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }>
type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }>
async function addVideoComments (commentUrls: string[]) {
return Bluebird.map(commentUrls, commentUrl => {

View File

@ -58,7 +58,7 @@ import {
MChannelDefault,
MChannelId,
MVideo,
MVideoAccountAllFiles,
MVideoAccountLightBlacklistAllFiles,
MVideoAccountLight,
MVideoAP,
MVideoAPWithoutCaption,
@ -213,19 +213,19 @@ function getOrCreateVideoAndAccountAndChannel (options: {
syncParam?: SyncParam,
fetchType?: 'all',
allowRefresh?: boolean
}): Promise<{ video: MVideoAccountAllFiles, created: boolean, autoBlacklisted?: boolean }>
}): Promise<{ video: MVideoAccountLightBlacklistAllFiles, created: boolean, autoBlacklisted?: boolean }>
function getOrCreateVideoAndAccountAndChannel (options: {
videoObject: { id: string } | string,
syncParam?: SyncParam,
fetchType?: VideoFetchByUrlType,
allowRefresh?: boolean
}): Promise<{ video: MVideoAccountAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }>
}): Promise<{ video: MVideoAccountLightBlacklistAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }>
async function getOrCreateVideoAndAccountAndChannel (options: {
videoObject: { id: string } | string,
syncParam?: SyncParam,
fetchType?: VideoFetchByUrlType,
allowRefresh?: boolean // true by default
}): Promise<{ video: MVideoAccountAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> {
}): Promise<{ video: MVideoAccountLightBlacklistAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> {
// Default params
const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false }
const fetchType = options.fetchType || 'all'
@ -263,7 +263,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: {
}
async function updateVideoFromAP (options: {
video: MVideoAccountAllFiles,
video: MVideoAccountLightBlacklistAllFiles,
videoObject: VideoTorrentObject,
account: MAccountActor,
channel: MChannelDefault,
@ -420,7 +420,7 @@ async function refreshVideoIfNeeded (options: {
// We need more attributes if the argument video was fetched with not enough joints
const video = options.fetchedType === 'all'
? options.video as MVideoAccountAllFiles
? options.video as MVideoAccountLightBlacklistAllFiles
: await VideoModel.loadByUrlAndPopulateAccount(options.video.url)
try {

View File

@ -11,11 +11,11 @@ import { sequelizeTypescript } from '../initializers/database'
import * as LRUCache from 'lru-cache'
import { queue } from 'async'
import { downloadImage } from '../helpers/requests'
import { MAccountActorDefault, MChannelActorDefault } from '../typings/models'
import { MAccountDefault, MChannelDefault } from '../typings/models'
async function updateActorAvatarFile (
avatarPhysicalFile: Express.Multer.File,
accountOrChannel: MAccountActorDefault | MChannelActorDefault
accountOrChannel: MAccountDefault | MChannelDefault
) {
const extension = extname(avatarPhysicalFile.filename)
const avatarName = uuidv4() + extension

View File

@ -2,14 +2,12 @@ import { createTransport, Transporter } from 'nodemailer'
import { isTestInstance } from '../helpers/core-utils'
import { bunyanLogger, logger } from '../helpers/logger'
import { CONFIG } from '../initializers/config'
import { UserModel } from '../models/account/user'
import { JobQueue } from './job-queue'
import { EmailPayload } from './job-queue/handlers/email'
import { readFileSync } from 'fs-extra'
import { VideoBlacklistModel } from '../models/video/video-blacklist'
import { WEBSERVER } from '../initializers/constants'
import { MCommentOwnerVideo, MVideo, MVideoAbuseVideo, MVideoAccountLight, MVideoBlacklistVideo } from '../typings/models/video'
import { MActorFollowActors, MActorFollowFull, MUser } from '../typings/models'
import { MActorFollowActors, MActorFollowFollowingFullFollowerAccount, MUser } from '../typings/models'
import { MVideoImport, MVideoImportVideo } from '@server/typings/models/video/video-import'
type SendEmailOptions = {
@ -109,7 +107,7 @@ class Emailer {
return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
}
addNewFollowNotification (to: string[], actorFollow: MActorFollowFull, followType: 'account' | 'channel') {
addNewFollowNotification (to: string[], actorFollow: MActorFollowFollowingFullFollowerAccount, followType: 'account' | 'channel') {
const followerName = actorFollow.ActorFollower.Account.getDisplayName()
const followingName = (actorFollow.ActorFollowing.VideoChannel || actorFollow.ActorFollowing.Account).getDisplayName()

View File

@ -10,7 +10,7 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { ActorModel } from '../../../models/activitypub/actor'
import { Notifier } from '../../notifier'
import { sequelizeTypescript } from '../../../initializers/database'
import { MActorFollowFull, MActorFull } from '../../../typings/models'
import { MAccount, MActor, MActorFollowActors, MActorFollowFull, MActorFull } from '../../../typings/models'
export type ActivitypubFollowPayload = {
followerActorId: number
@ -45,7 +45,7 @@ export {
// ---------------------------------------------------------------------------
async function follow (fromActor: MActorFull, targetActor: MActorFull) {
async function follow (fromActor: MActor, targetActor: MActorFull) {
if (fromActor.id === targetActor.id) {
throw new Error('Follower is the same than target actor.')
}
@ -54,7 +54,7 @@ async function follow (fromActor: MActorFull, targetActor: MActorFull) {
const state = !fromActor.serverId && !targetActor.serverId ? 'accepted' : 'pending'
const actorFollow = await sequelizeTypescript.transaction(async t => {
const [ actorFollow ] = await ActorFollowModel.findOrCreate<MActorFollowFull>({
const [ actorFollow ] = await ActorFollowModel.findOrCreate<MActorFollowActors>({
where: {
actorId: fromActor.id,
targetActorId: targetActor.id
@ -75,5 +75,14 @@ async function follow (fromActor: MActorFull, targetActor: MActorFull) {
return actorFollow
})
if (actorFollow.state === 'accepted') Notifier.Instance.notifyOfNewUserFollow(actorFollow)
if (actorFollow.state === 'accepted') {
const followerFull = Object.assign(fromActor, { Account: await actorFollow.ActorFollower.$get('Account') as MAccount })
const actorFollowFull = Object.assign(actorFollow, {
ActorFollowing: targetActor,
ActorFollower: followerFull
})
Notifier.Instance.notifyOfNewUserFollow(actorFollowFull)
}
}

View File

@ -111,13 +111,11 @@ type ProcessFileOptions = {
generateThumbnail: boolean
generatePreview: boolean
}
async function processFile (downloader: () => Promise<string>, videoImportArg: MVideoImportDefault, options: ProcessFileOptions) {
async function processFile (downloader: () => Promise<string>, videoImport: MVideoImportDefault, options: ProcessFileOptions) {
let tempVideoPath: string
let videoDestFile: string
let videoFile: VideoFileModel
const videoImport = videoImportArg as MVideoImportDefaultFiles
try {
// Download video from youtubeDL
tempVideoPath = await downloader()
@ -142,35 +140,37 @@ async function processFile (downloader: () => Promise<string>, videoImportArg: M
videoId: videoImport.videoId
}
videoFile = new VideoFileModel(videoFileData)
const videoWithFiles = Object.assign(videoImport.Video, { VideoFiles: [ videoFile ] })
// To clean files if the import fails
videoImport.Video.VideoFiles = [ videoFile ]
const videoImportWithFiles: MVideoImportDefaultFiles = Object.assign(videoImport, { Video: videoWithFiles })
// Move file
videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImport.Video.getVideoFilename(videoFile))
videoDestFile = join(CONFIG.STORAGE.VIDEOS_DIR, videoImportWithFiles.Video.getVideoFilename(videoFile))
await move(tempVideoPath, videoDestFile)
tempVideoPath = null // This path is not used anymore
// Process thumbnail
let thumbnailModel: MThumbnail
if (options.downloadThumbnail && options.thumbnailUrl) {
thumbnailModel = await createVideoMiniatureFromUrl(options.thumbnailUrl, videoImport.Video, ThumbnailType.MINIATURE)
thumbnailModel = await createVideoMiniatureFromUrl(options.thumbnailUrl, videoImportWithFiles.Video, ThumbnailType.MINIATURE)
} else if (options.generateThumbnail || options.downloadThumbnail) {
thumbnailModel = await generateVideoMiniature(videoImport.Video, videoFile, ThumbnailType.MINIATURE)
thumbnailModel = await generateVideoMiniature(videoImportWithFiles.Video, videoFile, ThumbnailType.MINIATURE)
}
// Process preview
let previewModel: MThumbnail
if (options.downloadPreview && options.thumbnailUrl) {
previewModel = await createVideoMiniatureFromUrl(options.thumbnailUrl, videoImport.Video, ThumbnailType.PREVIEW)
previewModel = await createVideoMiniatureFromUrl(options.thumbnailUrl, videoImportWithFiles.Video, ThumbnailType.PREVIEW)
} else if (options.generatePreview || options.downloadPreview) {
previewModel = await generateVideoMiniature(videoImport.Video, videoFile, ThumbnailType.PREVIEW)
previewModel = await generateVideoMiniature(videoImportWithFiles.Video, videoFile, ThumbnailType.PREVIEW)
}
// Create torrent
await videoImport.Video.createTorrentAndSetInfoHash(videoFile)
await videoImportWithFiles.Video.createTorrentAndSetInfoHash(videoFile)
const { videoImportUpdated, video } = await sequelizeTypescript.transaction(async t => {
const videoImportToUpdate = videoImport as MVideoImportVideo
const videoImportToUpdate = videoImportWithFiles as MVideoImportVideo
// Refresh video
const video = await VideoModel.load(videoImportToUpdate.videoId, t)

View File

@ -21,7 +21,7 @@ import {
MVideoFullLight
} from '../typings/models/video'
import { MUser, MUserAccount, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/typings/models/user'
import { MActorFollowActors, MActorFollowFull } from '../typings/models'
import { MActorFollowActors, MActorFollowFull, MActorFollowFollowingFullFollowerAccount } from '../typings/models'
import { ActorFollowModel } from '../models/activitypub/actor-follow'
import { MVideoImportVideo } from '@server/typings/models/video/video-import'
import { AccountModel } from '@server/models/account/account'
@ -102,7 +102,7 @@ class Notifier {
.catch(err => logger.error('Cannot notify moderators of new user registration (%s).', user.username, { err }))
}
notifyOfNewUserFollow (actorFollow: MActorFollowFull): void {
notifyOfNewUserFollow (actorFollow: MActorFollowFollowingFullFollowerAccount): void {
this.notifyUserOfNewActorFollow(actorFollow)
.catch(err => {
logger.error(
@ -231,7 +231,7 @@ class Notifier {
return this.notify({ users, settingGetter, notificationCreator, emailSender })
}
private async notifyUserOfNewActorFollow (actorFollow: MActorFollowFull) {
private async notifyUserOfNewActorFollow (actorFollow: MActorFollowFollowingFullFollowerAccount) {
if (actorFollow.ActorFollowing.isOwned() === false) return
// Account follows one of our account?

View File

@ -32,7 +32,9 @@ type CandidateToDuplicate = {
streamingPlaylists: MStreamingPlaylist[]
}
function isMVideoRedundancyFileVideo (o: MVideoRedundancyVideo): o is MVideoRedundancyFileVideo {
function isMVideoRedundancyFileVideo (
o: MVideoRedundancyFileVideo | MVideoRedundancyStreamingPlaylistVideo
): o is MVideoRedundancyFileVideo {
return !!(o as MVideoRedundancyFileVideo).VideoFile
}

View File

@ -13,8 +13,7 @@ import { isActorPreferredUsernameValid } from '../../../helpers/custom-validator
import { ActorModel } from '../../../models/activitypub/actor'
import { isBooleanValid } from '../../../helpers/custom-validators/misc'
import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares'
import { MChannelActorAccountDefault } from '../../../typings/models/video'
import { MUser } from '@server/typings/models'
import { MChannelAccountDefault, MUser } from '@server/typings/models'
const videoChannelsAddValidator = [
body('name').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'),
@ -132,7 +131,7 @@ export {
// ---------------------------------------------------------------------------
function checkUserCanDeleteVideoChannel (user: MUser, videoChannel: MChannelActorAccountDefault, res: express.Response) {
function checkUserCanDeleteVideoChannel (user: MUser, videoChannel: MChannelAccountDefault, res: express.Response) {
if (videoChannel.Actor.isOwned() === false) {
res.status(403)
.json({ error: 'Cannot remove video channel of another server.' })

View File

@ -44,7 +44,7 @@ import { isLocalVideoAccepted } from '../../../lib/moderation'
import { Hooks } from '../../../lib/plugins/hooks'
import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../../../helpers/middlewares'
import { MVideoFullLight } from '@server/typings/models'
import { getVideo } from '../../../helpers/video'
import { getVideoWithAttributes } from '../../../helpers/video'
const videosAddValidator = getCommonVideoEditAttributes().concat([
body('videofile')
@ -123,7 +123,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
])
async function checkVideoFollowConstraints (req: express.Request, res: express.Response, next: express.NextFunction) {
const video = getVideo(res)
const video = getVideoWithAttributes(res)
// Anybody can watch local videos
if (video.isOwned() === true) return next()
@ -157,7 +157,7 @@ const videosCustomGetValidator = (fetchType: 'all' | 'only-video' | 'only-video-
if (areValidationErrors(req, res)) return
if (!await doesVideoExist(req.params.id, res, fetchType)) return
const video = getVideo(res)
const video = getVideoWithAttributes(res)
const videoAll = video as MVideoFullLight
// Video private or blacklisted

View File

@ -55,7 +55,7 @@ import { UserAdminFlag } from '../../../shared/models/users/user-flag.model'
import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
import * as Bluebird from 'bluebird'
import { MUserChannel, MUserDefault, MUserId, MUserWithNotificationSetting } from '@server/typings/models'
import { MUserNotifSettingChannelDefault, MUserDefault, MUserId, MUserWithNotificationSetting } from '@server/typings/models'
enum ScopeNames {
WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL'
@ -384,7 +384,7 @@ export class UserModel extends Model<UserModel> {
return UserModel.findOne(query)
}
static loadByUsernameAndPopulateChannels (username: string): Bluebird<MUserChannel> {
static loadByUsernameAndPopulateChannels (username: string): Bluebird<MUserNotifSettingChannelDefault> {
const query = {
where: {
username: { [ Op.iLike ]: username }

View File

@ -37,7 +37,6 @@ import * as Bluebird from 'bluebird'
import {
MChannelAccountDefault,
MChannelActor,
MChannelActorAccountDefault,
MChannelActorAccountDefaultVideos
} from '../../typings/models/video'
@ -376,13 +375,13 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
})
}
static loadByIdAndPopulateAccount (id: number): Bluebird<MChannelActorAccountDefault> {
static loadByIdAndPopulateAccount (id: number): Bluebird<MChannelAccountDefault> {
return VideoChannelModel.unscoped()
.scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
.findByPk(id)
}
static loadByIdAndAccount (id: number, accountId: number): Bluebird<MChannelActorAccountDefault> {
static loadByIdAndAccount (id: number, accountId: number): Bluebird<MChannelAccountDefault> {
const query = {
where: {
id,
@ -395,7 +394,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
.findOne(query)
}
static loadAndPopulateAccount (id: number): Bluebird<MChannelActorAccountDefault> {
static loadAndPopulateAccount (id: number): Bluebird<MChannelAccountDefault> {
return VideoChannelModel.unscoped()
.scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
.findByPk(id)
@ -427,7 +426,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host)
}
static loadLocalByNameAndPopulateAccount (name: string): Bluebird<MChannelActorAccountDefault> {
static loadLocalByNameAndPopulateAccount (name: string): Bluebird<MChannelAccountDefault> {
const query = {
include: [
{
@ -446,7 +445,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
.findOne(query)
}
static loadByNameAndHostAndPopulateAccount (name: string, host: string): Bluebird<MChannelActorAccountDefault> {
static loadByNameAndHostAndPopulateAccount (name: string, host: string): Bluebird<MChannelAccountDefault> {
const query = {
include: [
{

View File

@ -121,18 +121,18 @@ import { createTorrentPromise } from '../../helpers/webtorrent'
import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
import {
MChannel,
MChannelActorAccountDefault,
MChannelAccountDefault,
MChannelId,
MUserAccountId,
MUserId,
MVideoAccountAllFiles,
MVideoAccountLight,
MVideoAccountLightBlacklistAllFiles,
MVideoDetails,
MVideoForUser,
MVideoFullLight,
MVideoIdThumbnail,
MVideoThumbnail,
MVideoWithAllFiles,
MVideoWithBlacklistThumbnailScheduled,
MVideoWithRights
} from '../../typings/models'
import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'
@ -1015,7 +1015,7 @@ export class VideoModel extends Model<VideoModel> {
AccountModel
],
transaction: options.transaction
}) as MChannelActorAccountDefault
}) as MChannelAccountDefault
}
return sendDeleteVideo(instance, options.transaction)
@ -1209,10 +1209,10 @@ export class VideoModel extends Model<VideoModel> {
return Promise.all([
VideoModel.count(countQuery),
VideoModel.scope(findScopes).findAll(findQuery)
VideoModel.scope(findScopes).findAll<MVideoForUser>(findQuery)
]).then(([ count, rows ]) => {
return {
data: rows as MVideoWithBlacklistThumbnailScheduled[],
data: rows,
total: count
}
})
@ -1468,7 +1468,7 @@ export class VideoModel extends Model<VideoModel> {
return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(query)
}
static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Bluebird<MVideoAccountAllFiles> {
static loadByUrlAndPopulateAccount (url: string, transaction?: Transaction): Bluebird<MVideoAccountLightBlacklistAllFiles> {
const query: FindOptions = {
where: {
url

View File

@ -5,7 +5,7 @@ import {
MActorFollowActorsDefault,
MActorFollowActorsDefaultSubscription,
MActorFull,
MChannelActorAccountDefault,
MChannelAccountDefault,
MComment,
MCommentOwnerVideoReply,
MUserDefault,
@ -53,7 +53,7 @@ declare module 'express' {
videoStreamingPlaylist?: MStreamingPlaylist
videoChannel?: MChannelActorAccountDefault
videoChannel?: MChannelAccountDefault
videoPlaylistFull?: MVideoPlaylistFull
videoPlaylistSummary?: MVideoPlaylistFullSummary

View File

@ -2,10 +2,16 @@ import { AccountBlocklistModel } from '../../../models/account/account-blocklist
import { PickWith } from '../../utils'
import { MAccountDefault } from './account'
type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M>
// ############################################################################
export type MAccountBlocklist = Omit<AccountBlocklistModel, 'ByAccount' | 'BlockedAccount'>
// ############################################################################
export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'>
export type MAccountBlocklistAccounts = MAccountBlocklist &
PickWith<AccountBlocklistModel, 'ByAccount', MAccountDefault> &
PickWith<AccountBlocklistModel, 'BlockedAccount', MAccountDefault>
Use<'ByAccount', MAccountDefault> &
Use<'BlockedAccount', MAccountDefault>

View File

@ -5,7 +5,8 @@ import {
MActorAPI,
MActorAudience,
MActorDefault,
MActorDefaultLight, MActorId,
MActorDefaultLight,
MActorId,
MActorServer,
MActorSummary,
MActorUrl
@ -14,43 +15,63 @@ import { PickWith } from '../../utils'
import { MAccountBlocklistId } from './account-blocklist'
import { MChannelDefault } from '@server/typings/models'
export type MAccountId = Pick<AccountModel, 'id'>
export type MAccountIdActor = MAccountId &
PickWith<AccountModel, 'Actor', MActorAccountChannelId>
export type MAccountIdActorId = MAccountId &
PickWith<AccountModel, 'Actor', MActorId>
type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
// ############################################################################
export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
'VideoComments' | 'BlockedAccounts'>
// Default scope
export type MAccountDefault = MAccount &
PickWith<AccountModel, 'Actor', MActorDefault>
export type MAccountDefaultChannelDefault = MAccountDefault &
PickWith<AccountModel, 'VideoChannels', MChannelDefault[]>
export type MAccountLight = MAccount &
PickWith<AccountModel, 'Actor', MActorDefaultLight>
// ############################################################################
// Only some attributes
export type MAccountId = Pick<MAccount, 'id'>
export type MAccountUserId = Pick<MAccount, 'userId'>
export type MAccountActor = MAccount &
PickWith<AccountModel, 'Actor', MActor>
export type MAccountServer = MAccountActor &
PickWith<AccountModel, 'Actor', MActorServer>
// Only some Actor attributes
export type MAccountUrl = Use<'Actor', MActorUrl>
export type MAccountAudience = Use<'Actor', MActorAudience>
export type MAccountActorDefault = MAccount &
PickWith<AccountModel, 'Actor', MActorDefault>
export type MAccountIdActor = MAccountId &
Use<'Actor', MActorAccountChannelId>
export type MAccountIdActorId = MAccountId &
Use<'Actor', MActorId>
// ############################################################################
// Default scope
export type MAccountDefault = MAccount &
Use<'Actor', MActorDefault>
// Default with default association scopes
export type MAccountDefaultChannelDefault = MAccount &
Use<'Actor', MActorDefault> &
Use<'VideoChannels', MChannelDefault[]>
// We don't need some actors attributes
export type MAccountLight = MAccount &
Use<'Actor', MActorDefaultLight>
// ############################################################################
// Full actor
export type MAccountActor = MAccount &
Use<'Actor', MActor>
// Full actor with server
export type MAccountServer = MAccount &
Use<'Actor', MActorServer>
// ############################################################################
// For API
export type MAccountSummary = Pick<MAccount, 'id' | 'name'> &
PickWith<AccountModel, 'Actor', MActorSummary>
Use<'Actor', MActorSummary>
export type MAccountBlocks = MAccountSummary &
PickWith<AccountModel, 'BlockedAccounts', MAccountBlocklistId[]>
export type MAccountSummaryBlocks = MAccountSummary &
Use<'BlockedAccounts', MAccountBlocklistId[]>
export type MAccountAPI = MAccountDefault &
PickWith<AccountModel, 'Actor', MActorAPI>
export type MAccountUrl = PickWith<AccountModel, 'Actor', MActorUrl>
export type MAccountAudience = PickWith<AccountModel, 'Actor', MActorAudience>
export type MAccountAPI = MAccount &
Use<'Actor', MActorAPI>

View File

@ -1,27 +1,55 @@
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { MActor, MActorAccountChannel, MActorChannel, MActorChannelAccount, MActorDefault, MActorHost, MActorUsername } from './actor'
import {
MActor,
MActorAccount,
MActorAccountChannel,
MActorChannel,
MActorChannelAccountActor,
MActorDefault,
MActorHost,
MActorUsername
} from './actor'
import { PickWith } from '../../utils'
import { ActorModel } from '@server/models/activitypub/actor'
type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>
// ############################################################################
export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'>
export type MActorFollowActors = MActorFollow &
PickWith<ActorFollowModel, 'ActorFollower', MActor> &
PickWith<ActorFollowModel, 'ActorFollowing', MActor>
export type MActorFollowActorsDefault = MActorFollow &
PickWith<ActorFollowModel, 'ActorFollower', MActorDefault> &
PickWith<ActorFollowModel, 'ActorFollowing', MActorDefault>
export type MActorFollowActorsDefaultSubscription = MActorFollow &
PickWith<ActorFollowModel, 'ActorFollower', MActorDefault> &
PickWith<ActorFollowModel, 'ActorFollowing', MActorDefault & MActorChannel>
export type MActorFollowFull = MActorFollow &
PickWith<ActorFollowModel, 'ActorFollower', MActorAccountChannel> &
PickWith<ActorFollowModel, 'ActorFollowing', MActorAccountChannel>
// ############################################################################
export type MActorFollowFollowingHost = MActorFollow &
PickWith<ActorFollowModel, 'ActorFollowing', MActorUsername & MActorHost>
Use<'ActorFollowing', MActorUsername & MActorHost>
// ############################################################################
// With actors or actors default
export type MActorFollowActors = MActorFollow &
Use<'ActorFollower', MActor> &
Use<'ActorFollowing', MActor>
export type MActorFollowActorsDefault = MActorFollow &
Use<'ActorFollower', MActorDefault> &
Use<'ActorFollowing', MActorDefault>
export type MActorFollowFull = MActorFollow &
Use<'ActorFollower', MActorAccountChannel> &
Use<'ActorFollowing', MActorAccountChannel>
// ############################################################################
// For subscriptions
export type MActorFollowActorsDefaultSubscription = MActorFollow &
Use<'ActorFollower', MActorDefault> &
Use<'ActorFollowing', MActorDefault & MActorChannel>
export type MActorFollowFollowingFullFollowerAccount = MActorFollow &
Use<'ActorFollower', MActorAccount> &
Use<'ActorFollowing', MActorAccountChannel>
export type MActorFollowSubscriptions = MActorFollow &
PickWith<ActorFollowModel, 'ActorFollowing', MActorChannelAccount>
Use<'ActorFollowing', MActorChannelAccountActor>

View File

@ -1,74 +1,103 @@
import { ActorModel } from '../../../models/activitypub/actor'
import { PickWith } from '../../utils'
import { MAccount, MAccountActorDefault, MAccountId, MAccountIdActor } from './account'
import { MServerHost, MServerHostBlocks, MServer } from '../server'
import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
import { MServer, MServerHost, MServerHostBlocks } from '../server'
import { MAvatar } from './avatar'
import { MChannel, MChannelAccountActor, MChannelActorAccountDefault, MChannelId, MChannelIdActor } from '../video'
import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
// ############################################################################
export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'>
// ############################################################################
export type MActorUrl = Pick<MActor, 'url'>
export type MActorId = Pick<MActor, 'id'>
export type MActorUsername = Pick<MActor, 'preferredUsername'>
export type MActorHost = PickWith<ActorModel, 'Server', MServerHost>
export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
export type MActorAudience = MActorUrl & MActorFollowersUrl
export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
export type MActorSignature = MActorAccountChannelId
export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
// ############################################################################
// Some association attributes
export type MActorHost = Use<'Server', MServerHost>
export type MActorDefaultLight = MActorLight &
MActorHost &
PickWith<ActorModel, 'Avatar', MAvatar>
Use<'Server', MServerHost> &
Use<'Avatar', MAvatar>
export type MActorAccountId = MActor &
PickWith<ActorModel, 'Account', MAccountId>
Use<'Account', MAccountId>
export type MActorAccountIdActor = MActor &
PickWith<ActorModel, 'Account', MAccountIdActor>
Use<'Account', MAccountIdActor>
export type MActorChannelId = MActor &
PickWith<ActorModel, 'VideoChannel', MChannelId>
Use<'VideoChannel', MChannelId>
export type MActorChannelIdActor = MActor &
PickWith<ActorModel, 'VideoChannel', MChannelIdActor>
Use<'VideoChannel', MChannelIdActor>
export type MActorAccountChannelId = MActorAccountId & MActorChannelId
export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
// ############################################################################
// Include raw account/channel/server
export type MActorAccount = MActor &
PickWith<ActorModel, 'Account', MAccount>
Use<'Account', MAccount>
export type MActorChannel = MActor &
PickWith<ActorModel, 'VideoChannel', MChannel>
Use<'VideoChannel', MChannel>
export type MActorAccountChannel = MActorAccount & MActorChannel
export type MActorChannelAccount = MActor &
PickWith<ActorModel, 'VideoChannel', MChannelAccountActor>
export type MActorServer = MActor &
PickWith<ActorModel, 'Server', MServer>
Use<'Server', MServer>
export type MActorDefault = MActorServer &
PickWith<ActorModel, 'Avatar', MAvatar>
// ############################################################################
export type MActorFull = MActorDefault &
PickWith<ActorModel, 'Account', MAccount> &
PickWith<ActorModel, 'VideoChannel', MChannelAccountActor>
// Complex actor associations
export type MActorFullActor = MActorDefault &
PickWith<ActorModel, 'Account', MAccountActorDefault> &
PickWith<ActorModel, 'VideoChannel', MChannelActorAccountDefault>
export type MActorDefault = MActor &
Use<'Server', MServer> &
Use<'Avatar', MAvatar>
// Actor with channel that is associated to an account and its actor
// Actor -> VideoChannel -> Account -> Actor
export type MActorChannelAccountActor = MActor &
Use<'VideoChannel', MChannelAccountActor>
export type MActorFull = MActor &
Use<'Server', MServer> &
Use<'Avatar', MAvatar> &
Use<'Account', MAccount> &
Use<'VideoChannel', MChannelAccountActor>
// Same than ActorFull, but the account and the channel have their actor
export type MActorFullActor = MActor &
Use<'Server', MServer> &
Use<'Avatar', MAvatar> &
Use<'Account', MAccountDefault> &
Use<'VideoChannel', MChannelAccountDefault>
// ############################################################################
// API
export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
MActorHost &
PickWith<ActorModel, 'Avatar', MAvatar>
Use<'Server', MServerHost> &
Use<'Avatar', MAvatar>
export type MActorSummaryBlocks = Omit<MActorSummary, 'Server'> &
PickWith<ActorModel, 'Server', MServerHostBlocks>
export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
export type MActorSummaryBlocks = MActorSummary &
Use<'Server', MServerHostBlocks>
export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
export type MActorSignature = MActorAccountChannelId

View File

@ -1,4 +1,5 @@
export * from './account'
export * from './oauth'
export * from './server'
export * from './user'
export * from './video'

View File

@ -0,0 +1,2 @@
export * from './oauth-client'
export * from './oauth-token'

View File

@ -2,8 +2,12 @@ import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
import { PickWith } from '@server/typings/utils'
import { MUserAccountUrl } from '@server/typings/models'
type Use<K extends keyof OAuthTokenModel, M> = PickWith<OAuthTokenModel, K, M>
// ############################################################################
export type MOAuthToken = Omit<OAuthTokenModel, 'User' | 'OAuthClients'>
export type MOAuthTokenUser = MOAuthToken &
PickWith<OAuthTokenModel, 'User', MUserAccountUrl> &
Use<'User', MUserAccountUrl> &
{ user?: MUserAccountUrl }

View File

@ -2,8 +2,14 @@ import { ServerBlocklistModel } from '@server/models/server/server-blocklist'
import { PickWith } from '@server/typings/utils'
import { MAccountDefault, MServer } from '@server/typings/models'
type Use<K extends keyof ServerBlocklistModel, M> = PickWith<ServerBlocklistModel, K, M>
// ############################################################################
export type MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'BlockedServer'>
// ############################################################################
export type MServerBlocklistAccountServer = MServerBlocklist &
PickWith<ServerBlocklistModel, 'ByAccount', MAccountDefault> &
PickWith<ServerBlocklistModel, 'BlockedServer', MServer>
Use<'ByAccount', MAccountDefault> &
Use<'BlockedServer', MServer>

View File

@ -2,9 +2,15 @@ import { ServerModel } from '../../../models/server/server'
import { PickWith } from '../../utils'
import { MAccountBlocklistId } from '../account'
type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M>
// ############################################################################
export type MServer = Omit<ServerModel, 'Actors' | 'BlockedByAccounts'>
// ############################################################################
export type MServerHost = Pick<MServer, 'host'>
export type MServerHostBlocks = MServerHost &
PickWith<ServerModel, 'BlockedByAccounts', MAccountBlocklistId[]>
Use<'BlockedByAccounts', MAccountBlocklistId[]>

View File

@ -1,3 +1,4 @@
export * from './user'
export * from './user-notification'
export * from './user-notification-setting'
export * from './user-video-history'

View File

@ -12,6 +12,10 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
import { VideoImportModel } from '../../../models/video/video-import'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M>
// ############################################################################
export namespace UserNotificationIncludes {
export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
export type VideoIncludeChannel = VideoInclude &
@ -56,14 +60,18 @@ export namespace UserNotificationIncludes {
PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
}
export type UserNotificationModelOnly = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
// ############################################################################
export type MUserNotification = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
'VideoImport' | 'Account' | 'ActorFollow'>
export type UserNotificationModelForApi = UserNotificationModelOnly &
PickWith<UserNotificationModel, 'Video', UserNotificationIncludes.VideoIncludeChannel> &
PickWith<UserNotificationModel, 'Comment', UserNotificationIncludes.VideoCommentInclude> &
PickWith<UserNotificationModel, 'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
PickWith<UserNotificationModel, 'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
PickWith<UserNotificationModel, 'VideoImport', UserNotificationIncludes.VideoImportInclude> &
PickWith<UserNotificationModel, 'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
PickWith<UserNotificationModel, 'Account', UserNotificationIncludes.AccountIncludeActor>
// ############################################################################
export type UserNotificationModelForApi = MUserNotification &
Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
Use<'Account', UserNotificationIncludes.AccountIncludeActor>

View File

@ -3,30 +3,49 @@ import { PickWith } from '../../utils'
import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'
import { MNotificationSetting } from './user-notification-setting'
type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
// ############################################################################
export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
// ############################################################################
export type MUserId = Pick<UserModel, 'id'>
export type MUserWithNotificationSetting = MUser &
PickWith<UserModel, 'NotificationSetting', MNotificationSetting>
// ############################################################################
export type MUserAccountDefault = MUser &
PickWith<UserModel, 'Account', MAccountDefault>
export type MUserAccount = MUser &
PickWith<UserModel, 'Account', MAccount>
// With account
export type MUserAccountId = MUser &
PickWith<UserModel, 'Account', MAccountId>
export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount
export type MUserDefault = MUser &
MUserWithNotificationSetting &
MUserAccountDefault
export type MUserChannel = MUserWithNotificationSetting &
PickWith<UserModel, 'Account', MAccountDefaultChannelDefault>
Use<'Account', MAccountId>
export type MUserAccountUrl = MUser &
PickWith<UserModel, 'Account', MAccountUrl & MAccountIdActorId>
Use<'Account', MAccountUrl & MAccountIdActorId>
export type MUserAccount = MUser &
Use<'Account', MAccount>
export type MUserAccountDefault = MUser &
Use<'Account', MAccountDefault>
// With channel
export type MUserNotifSettingChannelDefault = MUser &
Use<'NotificationSetting', MNotificationSetting> &
Use<'Account', MAccountDefaultChannelDefault>
// With notification settings
export type MUserWithNotificationSetting = MUser &
Use<'NotificationSetting', MNotificationSetting>
export type MUserNotifSettingAccount = MUser &
Use<'NotificationSetting', MNotificationSetting> &
Use<'Account', MAccount>
// Default scope
export type MUserDefault = MUser &
Use<'NotificationSetting', MNotificationSetting> &
Use<'Account', MAccountDefault>

View File

@ -5,10 +5,14 @@ export * from './video'
export * from './video-abuse'
export * from './video-blacklist'
export * from './video-caption'
export * from './video-change-ownership'
export * from './video-channels'
export * from './video-comment'
export * from './video-file'
export * from './video-import'
export * from './video-playlist'
export * from './video-playlist-element'
export * from './video-rate'
export * from './video-redundancy'
export * from './video-share'
export * from './video-streaming-playlist'

View File

@ -3,13 +3,21 @@ import { PickWith } from '../../utils'
import { MVideo } from './video'
import { MAccountDefault } from '../account'
type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M>
// ############################################################################
export type MVideoAbuse = Omit<VideoAbuseModel, 'Account' | 'Video' | 'toActivityPubObject'>
// ############################################################################
export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'>
export type MVideoAbuseVideo = MVideoAbuse &
Pick<VideoAbuseModel, 'toActivityPubObject'> &
PickWith<VideoAbuseModel, 'Video', MVideo>
Use<'Video', MVideo>
export type MVideoAbuseAccountVideo = MVideoAbuseVideo &
PickWith<VideoAbuseModel, 'Account', MAccountDefault>
export type MVideoAbuseAccountVideo = MVideoAbuse &
Pick<VideoAbuseModel, 'toActivityPubObject'> &
Use<'Video', MVideo> &
Use<'Account', MAccountDefault>

View File

@ -2,10 +2,16 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
import { PickWith } from '@server/typings/utils'
import { MVideo } from '@server/typings/models'
type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M>
// ############################################################################
export type MVideoBlacklist = Omit<VideoBlacklistModel, 'Video'>
export type MVideoBlacklistLight = Pick<MVideoBlacklist, 'id' | 'reason' | 'unfederated'>
export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'>
// ############################################################################
export type MVideoBlacklistVideo = MVideoBlacklist &
PickWith<VideoBlacklistModel, 'Video', MVideo>
Use<'Video', MVideo>

View File

@ -2,9 +2,15 @@ import { VideoCaptionModel } from '../../../models/video/video-caption'
import { PickWith } from '@server/typings/utils'
import { VideoModel } from '@server/models/video/video'
type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M>
// ############################################################################
export type MVideoCaption = Omit<VideoCaptionModel, 'Video'>
// ############################################################################
export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'>
export type MVideoCaptionVideo = MVideoCaption &
PickWith<VideoCaptionModel, 'Video', Pick<VideoModel, 'id' | 'remote' | 'uuid'>>
Use<'Video', Pick<VideoModel, 'id' | 'remote' | 'uuid'>>

View File

@ -2,9 +2,13 @@ import { VideoChangeOwnershipModel } from '@server/models/video/video-change-own
import { PickWith } from '@server/typings/utils'
import { MAccountDefault, MVideoWithFileThumbnail } from '@server/typings/models'
type Use<K extends keyof VideoChangeOwnershipModel, M> = PickWith<VideoChangeOwnershipModel, K, M>
// ############################################################################
export type MVideoChangeOwnership = Omit<VideoChangeOwnershipModel, 'Initiator' | 'NextOwner' | 'Video'>
export type MVideoChangeOwnershipFull = MVideoChangeOwnership &
PickWith<VideoChangeOwnershipModel, 'Initiator', MAccountDefault> &
PickWith<VideoChangeOwnershipModel, 'NextOwner', MAccountDefault> &
PickWith<VideoChangeOwnershipModel, 'Video', MVideoWithFileThumbnail>
Use<'Initiator', MAccountDefault> &
Use<'NextOwner', MAccountDefault> &
Use<'Video', MVideoWithFileThumbnail>

View File

@ -1,70 +1,97 @@
import { FunctionProperties, PickWith } from '../../utils'
import { PickWith } from '../../utils'
import { VideoChannelModel } from '../../../models/video/video-channel'
import {
MAccountActor,
MAccountAPI,
MAccountBlocks,
MAccountDefault,
MAccountLight,
MAccountSummaryBlocks,
MAccountUserId,
MActor,
MActorAccountChannelId,
MActorAPI,
MActorDefault,
MActorDefaultLight, MActorLight,
MActorDefaultLight,
MActorLight,
MActorSummary
} from '../account'
import { MVideo } from './video'
export type MChannelId = FunctionProperties<VideoChannelModel>
export type MChannelIdActor = MChannelId &
PickWith<VideoChannelModel, 'Actor', MActorAccountChannelId>
type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
// ############################################################################
export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
// ############################################################################
export type MChannelId = Pick<MChannel, 'id'>
// ############################################################################
export type MChannelIdActor = MChannelId &
Use<'Actor', MActorAccountChannelId>
export type MChannelUserId = Pick<MChannel, 'accountId'> &
PickWith<VideoChannelModel, 'Account', MAccountUserId>
Use<'Account', MAccountUserId>
export type MChannelActor = MChannel &
Use<'Actor', MActor>
// Default scope
export type MChannelDefault = MChannel &
PickWith<VideoChannelModel, 'Actor', MActorDefault>
Use<'Actor', MActorDefault>
// ############################################################################
// Not all association attributes
export type MChannelLight = MChannel &
PickWith<VideoChannelModel, 'Actor', MActorDefaultLight>
Use<'Actor', MActorDefaultLight>
export type MChannelActorLight = MChannel &
Use<'Actor', MActorLight>
export type MChannelAccountLight = MChannel &
PickWith<VideoChannelModel, 'Actor', MActorDefaultLight> &
PickWith<VideoChannelModel, 'Account', MAccountLight>
Use<'Actor', MActorDefaultLight> &
Use<'Account', MAccountLight>
export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
PickWith<VideoChannelModel, 'Actor', MActorSummary>
// ############################################################################
export type MChannelSummaryAccount = MChannelSummary &
PickWith<VideoChannelModel, 'Account', MAccountBlocks>
export type MChannelAPI = MChannel &
PickWith<VideoChannelModel, 'Actor', MActorAPI> &
PickWith<VideoChannelModel, 'Account', MAccountAPI>
// Account associations
export type MChannelAccountActor = MChannel &
PickWith<VideoChannelModel, 'Account', MAccountActor>
export type MChannelAccountDefault = MChannelActor &
PickWith<VideoChannelModel, 'Account', MAccountDefault>
Use<'Account', MAccountActor>
export type MChannelAccountDefault = MChannel &
Use<'Actor', MActorDefault> &
Use<'Account', MAccountDefault>
export type MChannelActorAccountActor = MChannel &
Use<'Account', MAccountActor> &
Use<'Actor', MActor>
// ############################################################################
// Videos associations
export type MChannelVideos = MChannel &
PickWith<VideoChannelModel, 'Videos', MVideo[]>
Use<'Videos', MVideo[]>
export type MChannelActor = MChannel &
PickWith<VideoChannelModel, 'Actor', MActor>
export type MChannelActorLight = MChannel &
PickWith<VideoChannelModel, 'Actor', MActorLight>
export type MChannelActorDefault = MChannel &
PickWith<VideoChannelModel, 'Actor', MActorDefault>
export type MChannelActorAccountDefaultVideos = MChannel &
Use<'Actor', MActorDefault> &
Use<'Account', MAccountDefault> &
Use<'Videos', MVideo[]>
export type MChannelActorAccountActor = MChannelAccountActor & MChannelActor
// ############################################################################
export type MChannelActorAccountDefault = MChannel &
PickWith<VideoChannelModel, 'Actor', MActorDefault> &
PickWith<VideoChannelModel, 'Account', MAccountDefault>
// For API
export type MChannelActorAccountDefaultVideos = MChannelActorAccountDefault & MChannelVideos
export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
Use<'Actor', MActorSummary>
export type MChannelSummaryAccount = MChannelSummary &
Use<'Account', MAccountSummaryBlocks>
export type MChannelAPI = MChannel &
Use<'Actor', MActorAPI> &
Use<'Account', MAccountAPI>

View File

@ -1,29 +1,43 @@
import { VideoCommentModel } from '../../../models/video/video-comment'
import { PickWith } from '../../utils'
import { MAccountDefault } from '../account'
import { MVideoAccountDefault, MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video'
import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video'
type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M>
// ############################################################################
export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'>
export type MCommentId = Pick<MComment, 'id'>
export type MCommentAPI = MComment & { totalReplies: number }
// ############################################################################
export type MCommentOwner = MComment &
PickWith<VideoCommentModel, 'Account', MAccountDefault>
Use<'Account', MAccountDefault>
export type MCommentVideo = MComment &
PickWith<VideoCommentModel, 'Video', MVideoAccountLight>
Use<'Video', MVideoAccountLight>
export type MCommentReply = MComment &
PickWith<VideoCommentModel, 'InReplyToVideoComment', MComment>
Use<'InReplyToVideoComment', MComment>
export type MCommentOwnerReply = MCommentOwner & MCommentReply
export type MCommentOwnerVideo = MCommentOwner & MCommentVideo
export type MCommentReplyVideo = MCommentReply & MCommentVideo
export type MCommentOwnerVideoReply = MCommentOwnerVideo & MCommentReply
export type MCommentOwnerVideo = MComment &
Use<'Account', MAccountDefault> &
Use<'Video', MVideoAccountLight>
export type MCommentOwnerReplyVideoLight = MCommentOwnerReply &
PickWith<VideoCommentModel, 'Video', MVideoIdUrl>
export type MCommentOwnerVideoReply = MComment &
Use<'Account', MAccountDefault> &
Use<'Video', MVideoAccountLight> &
Use<'InReplyToVideoComment', MComment>
export type MCommentOwnerReplyVideoLight = MComment &
Use<'Account', MAccountDefault> &
Use<'InReplyToVideoComment', MComment> &
Use<'Video', MVideoIdUrl>
export type MCommentOwnerVideoFeed = MCommentOwner &
PickWith<VideoCommentModel, 'Video', MVideoFeed>
Use<'Video', MVideoFeed>
// ############################################################################
export type MCommentAPI = MComment & { totalReplies: number }

View File

@ -3,13 +3,17 @@ import { PickWith, PickWithOpt } from '../../utils'
import { MVideo, MVideoUUID } from './video'
import { MVideoRedundancyFileUrl } from './video-redundancy'
type Use<K extends keyof VideoFileModel, M> = PickWith<VideoFileModel, K, M>
// ############################################################################
export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos'>
export type MVideoFileVideo = MVideoFile &
PickWith<VideoFileModel, 'Video', MVideo>
Use<'Video', MVideo>
export type MVideoFileVideoUUID = MVideoFile &
PickWith<VideoFileModel, 'Video', MVideoUUID>
Use<'Video', MVideoUUID>
export type MVideoFileRedundanciesOpt = MVideoFile &
PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>

View File

@ -2,14 +2,23 @@ import { VideoImportModel } from '@server/models/video/video-import'
import { PickWith } from '@server/typings/utils'
import { MUser, MVideo, MVideoAccountLight, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models'
type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M>
// ############################################################################
export type MVideoImport = Omit<VideoImportModel, 'User' | 'Video'>
export type MVideoImportDefault = MVideoImport &
PickWith<VideoImportModel, 'User', MUser> &
PickWith<VideoImportModel, 'Video', MVideoTag & MVideoAccountLight & MVideoThumbnail>
export type MVideoImportDefaultFiles = MVideoImportDefault &
PickWith<VideoImportModel, 'Video', MVideoTag & MVideoAccountLight & MVideoThumbnail & MVideoWithFile>
export type MVideoImportVideo = MVideoImport &
PickWith<VideoImportModel, 'Video', MVideo>
Use<'Video', MVideo>
// ############################################################################
type VideoAssociation = MVideoTag & MVideoAccountLight & MVideoThumbnail
export type MVideoImportDefault = MVideoImport &
Use<'User', MUser> &
Use<'Video', VideoAssociation>
export type MVideoImportDefaultFiles = MVideoImport &
Use<'User', MUser> &
Use<'Video', VideoAssociation & MVideoWithFile>

View File

@ -2,14 +2,27 @@ import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-e
import { PickWith } from '@server/typings/utils'
import { MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models'
type Use<K extends keyof VideoPlaylistElementModel, M> = PickWith<VideoPlaylistElementModel, K, M>
// ############################################################################
export type MVideoPlaylistElement = Omit<VideoPlaylistElementModel, 'VideoPlaylist' | 'Video'>
// ############################################################################
export type MVideoPlaylistElementId = Pick<MVideoPlaylistElement, 'id'>
export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'videoId' | 'startTimestamp' | 'stopTimestamp'>
// ############################################################################
export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement &
PickWith<VideoPlaylistElementModel, 'Video', MVideoThumbnail>
Use<'Video', MVideoThumbnail>
// ############################################################################
// For API
export type MVideoPlaylistAP = MVideoPlaylistElement &
PickWith<VideoPlaylistElementModel, 'Video', MVideoUrl> &
PickWith<VideoPlaylistElementModel, 'VideoPlaylist', MVideoPlaylistPrivacy>
Use<'Video', MVideoUrl> &
Use<'VideoPlaylist', MVideoPlaylistPrivacy>

View File

@ -5,38 +5,76 @@ import { MThumbnail } from './thumbnail'
import { MChannelDefault, MChannelSummary } from './video-channels'
import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element'
type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M>
// ############################################################################
export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'>
// ############################################################################
export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'>
export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'>
export type MVideoPlaylistWithElements = MVideoPlaylist &
PickWith<VideoPlaylistModel, 'VideoPlaylistElements', MVideoPlaylistElementLight[]>
export type MVideoPlaylistIdWithElements = MVideoPlaylistId & MVideoPlaylistWithElements
export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'>
export type MVideoPlaylistOwner = MVideoPlaylist &
PickWith<VideoPlaylistModel, 'OwnerAccount', MAccount>
export type MVideoPlaylistOwnerDefault = MVideoPlaylist &
PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountDefault>
export type MVideoPlaylistThumbnail = MVideoPlaylist &
PickWith<VideoPlaylistModel, 'Thumbnail', MThumbnail>
export type MVideoPlaylistAccountThumbnail = MVideoPlaylistOwnerDefault &
PickWith<VideoPlaylistModel, 'Thumbnail', MThumbnail>
export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist &
PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountSummary> &
PickWith<VideoPlaylistModel, 'VideoChannel', MChannelSummary>
export type MVideoPlaylistAccountChannelDefault = MVideoPlaylist &
PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountDefault> &
PickWith<VideoPlaylistModel, 'VideoChannel', MChannelDefault>
export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number }
export type MVideoPlaylistFullSummary = MVideoPlaylistAccountChannelSummary & MVideoPlaylistThumbnail
// ############################################################################
export type MVideoPlaylistFull = MVideoPlaylist & MVideoPlaylistThumbnail & MVideoPlaylistAccountChannelDefault
// With elements
export type MVideoPlaylistWithElements = MVideoPlaylist &
Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]>
export type MVideoPlaylistIdWithElements = MVideoPlaylistId &
Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]>
// ############################################################################
// With account
export type MVideoPlaylistOwner = MVideoPlaylist &
Use<'OwnerAccount', MAccount>
export type MVideoPlaylistOwnerDefault = MVideoPlaylist &
Use<'OwnerAccount', MAccountDefault>
// ############################################################################
// With thumbnail
export type MVideoPlaylistThumbnail = MVideoPlaylist &
Use<'Thumbnail', MThumbnail>
export type MVideoPlaylistAccountThumbnail = MVideoPlaylist &
Use<'OwnerAccount', MAccountDefault> &
Use<'Thumbnail', MThumbnail>
// ############################################################################
// With channel
export type MVideoPlaylistAccountChannelDefault = MVideoPlaylist &
Use<'OwnerAccount', MAccountDefault> &
Use<'VideoChannel', MChannelDefault>
// ############################################################################
// With all associations
export type MVideoPlaylistFull = MVideoPlaylist &
Use<'OwnerAccount', MAccountDefault> &
Use<'VideoChannel', MChannelDefault> &
Use<'Thumbnail', MThumbnail>
// ############################################################################
// For API
export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist &
Use<'OwnerAccount', MAccountSummary> &
Use<'VideoChannel', MChannelSummary>
export type MVideoPlaylistFullSummary = MVideoPlaylist &
Use<'Thumbnail', MThumbnail> &
Use<'OwnerAccount', MAccountSummary> &
Use<'VideoChannel', MChannelSummary>

View File

@ -2,11 +2,15 @@ import { AccountVideoRateModel } from '@server/models/account/account-video-rate
import { PickWith } from '@server/typings/utils'
import { MAccountAudience, MAccountUrl, MVideo } from '..'
type Use<K extends keyof AccountVideoRateModel, M> = PickWith<AccountVideoRateModel, K, M>
// ############################################################################
export type MAccountVideoRate = Omit<AccountVideoRateModel, 'Video' | 'Account'>
export type MAccountVideoRateAccountUrl = MAccountVideoRate &
PickWith<AccountVideoRateModel, 'Account', MAccountUrl>
Use<'Account', MAccountUrl>
export type MAccountVideoRateAccountVideo = MAccountVideoRate &
PickWith<AccountVideoRateModel, 'Account', MAccountAudience> &
PickWith<AccountVideoRateModel, 'Video', MVideo>
Use<'Account', MAccountAudience> &
Use<'Video', MVideo>

View File

@ -2,17 +2,25 @@ import { VideoRedundancyModel } from '../../../models/redundancy/video-redundanc
import { PickWith } from '@server/typings/utils'
import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo } from '@server/typings/models'
type Use<K extends keyof VideoRedundancyModel, M> = PickWith<VideoRedundancyModel, K, M>
// ############################################################################
export type MVideoRedundancy = Omit<VideoRedundancyModel, 'VideoFile' | 'VideoStreamingPlaylist' | 'Actor'>
export type MVideoRedundancyFileUrl = Pick<MVideoRedundancy, 'fileUrl'>
// ############################################################################
export type MVideoRedundancyFile = MVideoRedundancy &
PickWith<VideoRedundancyModel, 'VideoFile', MVideoFile>
Use<'VideoFile', MVideoFile>
export type MVideoRedundancyFileVideo = MVideoRedundancy &
PickWith<VideoRedundancyModel, 'VideoFile', MVideoFileVideo>
Use<'VideoFile', MVideoFileVideo>
export type MVideoRedundancyStreamingPlaylistVideo = MVideoRedundancy &
PickWith<VideoRedundancyModel, 'VideoStreamingPlaylist', MStreamingPlaylistVideo>
Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
export type MVideoRedundancyVideo = MVideoRedundancyFileVideo | MVideoRedundancyStreamingPlaylistVideo
export type MVideoRedundancyVideo = MVideoRedundancy &
Use<'VideoFile', MVideoFileVideo> &
Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>

View File

@ -3,10 +3,15 @@ import { PickWith } from '../../utils'
import { MActorDefault } from '../account'
import { MVideo } from './video'
type Use<K extends keyof VideoShareModel, M> = PickWith<VideoShareModel, K, M>
// ############################################################################
export type MVideoShare = Omit<VideoShareModel, 'Actor' | 'Video'>
export type MVideoShareActor = MVideoShare &
PickWith<VideoShareModel, 'Actor', MActorDefault>
Use<'Actor', MActorDefault>
export type MVideoShareFull = MVideoShareActor &
PickWith<VideoShareModel, 'Video', MVideo>
export type MVideoShareFull = MVideoShare &
Use<'Actor', MActorDefault> &
Use<'Video', MVideo>

View File

@ -3,10 +3,14 @@ import { PickWith } from '../../utils'
import { MVideoRedundancyFileUrl } from './video-redundancy'
import { MVideo } from '@server/typings/models'
type Use<K extends keyof VideoStreamingPlaylistModel, M> = PickWith<VideoStreamingPlaylistModel, K, M>
// ############################################################################
export type MStreamingPlaylist = Omit<VideoStreamingPlaylistModel, 'Video' | 'RedundancyVideos'>
export type MStreamingPlaylistVideo = MStreamingPlaylist &
PickWith<VideoStreamingPlaylistModel, 'Video', MVideo>
Use<'Video', MVideo>
export type MStreamingPlaylistRedundancies = MStreamingPlaylist &
PickWith<VideoStreamingPlaylistModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
Use<'RedundancyVideos', MVideoRedundancyFileUrl[]>

View File

@ -1,6 +1,6 @@
import { VideoModel } from '../../../models/video/video'
import { PickWith, PickWithOpt } from '../../utils'
import { MChannelAccountLight, MChannelActor, MChannelActorAccountDefault, MChannelUserId } from './video-channels'
import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels'
import { MTag } from './tag'
import { MVideoCaptionLanguage } from './video-caption'
import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'
@ -10,10 +10,16 @@ import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blackl
import { MScheduleVideoUpdate } from './schedule-video-update'
import { MUserVideoHistoryTime } from '../user/user-video-history'
type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
// ############################################################################
export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
// ############################################################################
export type MVideoId = Pick<MVideo, 'id'>
export type MVideoUrl = Pick<MVideo, 'url'>
export type MVideoUUID = Pick<MVideo, 'uuid'>
@ -21,83 +27,120 @@ export type MVideoUUID = Pick<MVideo, 'uuid'>
export type MVideoIdUrl = MVideoId & MVideoUrl
export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
// ############################################################################
// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
// "With" to not confuse with the VideoFile model
export type MVideoWithFile = MVideo &
PickWith<VideoModel, 'VideoFiles', MVideoFile[]>
Use<'VideoFiles', MVideoFile[]>
export type MVideoThumbnail = MVideo &
PickWith<VideoModel, 'Thumbnails', MThumbnail[]>
export type MVideoIdThumbnail = MVideoThumbnail & MVideoId
Use<'Thumbnails', MThumbnail[]>
export type MVideoIdThumbnail = MVideoId &
Use<'Thumbnails', MThumbnail[]>
export type MVideoWithFileThumbnail = MVideo &
Use<'VideoFiles', MVideoFile[]> &
Use<'Thumbnails', MThumbnail[]>
export type MVideoTag = MVideo &
PickWith<VideoModel, 'Tags', MTag[]>
Use<'Tags', MTag[]>
export type MVideoWithSchedule = MVideo &
PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
export type MVideoWithFileThumbnail = MVideoWithFile & MVideoThumbnail
export type MVideoUser = MVideo &
PickWith<VideoModel, 'VideoChannel', MChannelUserId>
export type MVideoWithCaptions = MVideo &
PickWith<VideoModel, 'VideoCaptions', MVideoCaptionLanguage[]>
export type MVideoWithBlacklistLight = MVideo &
PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistLight>
export type MVideoAccountLight = MVideo &
PickWith<VideoModel, 'VideoChannel', MChannelAccountLight>
export type MVideoWithRights = MVideoWithBlacklistLight & MVideoThumbnail & MVideoUser
Use<'VideoCaptions', MVideoCaptionLanguage[]>
export type MVideoWithStreamingPlaylist = MVideo &
PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylist[]>
Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
export type MVideoWithAllFiles = MVideoWithFileThumbnail & MVideoWithStreamingPlaylist
// ############################################################################
export type MVideoAccountAllFiles = MVideoWithAllFiles & MVideoAccountLight & MVideoWithBlacklistLight
export type MVideoAccountAllFilesCaptions = MVideoAccountAllFiles & MVideoWithCaptions
// Associations with not all their attributes
export type MVideoUserHistory = MVideo &
PickWith<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]>
Use<'UserVideoHistories', MUserVideoHistoryTime[]>
export type MVideoWithBlacklistThumbnailScheduled = MVideoWithSchedule & MVideoWithBlacklistLight & MVideoWithFileThumbnail
export type MVideoWithBlacklistLight = MVideo &
Use<'VideoBlacklist', MVideoBlacklistLight>
export type MVideoAccountLight = MVideo &
Use<'VideoChannel', MChannelAccountLight>
export type MVideoWithRights = MVideo &
Use<'VideoBlacklist', MVideoBlacklistLight> &
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoChannel', MChannelUserId>
// ############################################################################
// All files with some additional associations
export type MVideoWithAllFiles = MVideo &
Use<'VideoFiles', MVideoFile[]> &
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
export type MVideoAccountLightBlacklistAllFiles = MVideo &
Use<'VideoFiles', MVideoFile[]> &
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
Use<'VideoChannel', MChannelAccountLight> &
Use<'VideoBlacklist', MVideoBlacklistLight>
// ############################################################################
// With account
export type MVideoAccountDefault = MVideo &
PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault>
Use<'VideoChannel', MChannelAccountDefault>
export type MVideoThumbnailAccountDefault = MVideoThumbnail &
PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault>
export type MVideoThumbnailAccountDefault = MVideo &
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoChannel', MChannelAccountDefault>
export type MVideoWithChannelActor = MVideo &
PickWith<VideoModel, 'VideoChannel', MChannelActor>
Use<'VideoChannel', MChannelActor>
export type MVideoFullLight = MVideoThumbnail &
MVideoWithBlacklistLight &
MVideoTag &
MVideoAccountLight &
MVideoUserHistory &
MVideoWithFile &
MVideoWithSchedule &
MVideoWithStreamingPlaylist &
MVideoUserHistory
export type MVideoFullLight = MVideo &
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoBlacklist', MVideoBlacklistLight> &
Use<'Tags', MTag[]> &
Use<'VideoChannel', MChannelAccountLight> &
Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
Use<'VideoFiles', MVideoFile[]> &
Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
// ############################################################################
// API
export type MVideoAP = MVideo &
MVideoTag &
MVideoAccountLight &
MVideoWithStreamingPlaylist &
MVideoWithCaptions &
PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistUnfederated> &
PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]>
Use<'Tags', MTag[]> &
Use<'VideoChannel', MChannelAccountLight> &
Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
Use<'VideoCaptions', MVideoCaptionLanguage[]> &
Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
export type MVideoDetails = MVideo &
MVideoWithBlacklistLight &
MVideoTag &
MVideoAccountLight &
MVideoWithSchedule &
MVideoThumbnail &
MVideoUserHistory &
PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]>
Use<'VideoBlacklist', MVideoBlacklistLight> &
Use<'Tags', MTag[]> &
Use<'VideoChannel', MChannelAccountLight> &
Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
Use<'Thumbnails', MThumbnail[]> &
Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
export type MVideoForUser = MVideo &
Use<'VideoChannel', MChannelAccountDefault> &
Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
Use<'VideoBlacklist', MVideoBlacklistLight> &
Use<'Thumbnails', MThumbnail[]>