Cleanup model types
This commit is contained in:
parent
96ca24f00e
commit
0283eaac2a
|
@ -19,7 +19,7 @@ import { getOrCreateActorAndServerAndModel, getOrCreateVideoAndAccountAndChannel
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
import { VideoChannelModel } from '../../models/video/video-channel'
|
import { VideoChannelModel } from '../../models/video/video-channel'
|
||||||
import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger'
|
import { loadActorUrlOrGetFromWebfinger } from '../../helpers/webfinger'
|
||||||
import { MChannelAccountDefault, MVideoAccountAllFiles } from '../../typings/models'
|
import { MChannelAccountDefault, MVideoAccountLightBlacklistAllFiles } from '../../typings/models'
|
||||||
|
|
||||||
const searchRouter = express.Router()
|
const searchRouter = express.Router()
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ async function searchVideosDB (query: VideosSearchQuery, res: express.Response)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchVideoURI (url: string, 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
|
// Check if we can fetch a remote video with the URL
|
||||||
if (isUserAbleToSearchRemoteURI(res)) {
|
if (isUserAbleToSearchRemoteURI(res)) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import { sequelizeTypescript } from '../../../initializers/database'
|
||||||
import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail'
|
import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail'
|
||||||
import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
|
import { ThumbnailType } from '../../../../shared/models/videos/thumbnail.type'
|
||||||
import {
|
import {
|
||||||
MChannelActorAccountDefault,
|
MChannelAccountDefault,
|
||||||
MThumbnail,
|
MThumbnail,
|
||||||
MUser,
|
MUser,
|
||||||
MVideoTag,
|
MVideoTag,
|
||||||
|
@ -234,7 +234,7 @@ function insertIntoDB (parameters: {
|
||||||
video: MVideoThumbnailAccountDefault,
|
video: MVideoThumbnailAccountDefault,
|
||||||
thumbnailModel: MThumbnail,
|
thumbnailModel: MThumbnail,
|
||||||
previewModel: MThumbnail,
|
previewModel: MThumbnail,
|
||||||
videoChannel: MChannelActorAccountDefault,
|
videoChannel: MChannelAccountDefault,
|
||||||
tags: string[],
|
tags: string[],
|
||||||
videoImportAttributes: Partial<MVideoImport>,
|
videoImportAttributes: Partial<MVideoImport>,
|
||||||
user: MUser
|
user: MUser
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as express from 'express'
|
import * as express from 'express'
|
||||||
import { VideoChannelModel } from '../../models/video/video-channel'
|
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) {
|
async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
|
||||||
const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
|
const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
|
||||||
|
@ -28,7 +28,7 @@ export {
|
||||||
doesVideoChannelNameWithHostExist
|
doesVideoChannelNameWithHostExist
|
||||||
}
|
}
|
||||||
|
|
||||||
function processVideoChannelExist (videoChannel: MChannelActorAccountDefault, res: express.Response) {
|
function processVideoChannelExist (videoChannel: MChannelAccountDefault, res: express.Response) {
|
||||||
if (!videoChannel) {
|
if (!videoChannel) {
|
||||||
res.status(404)
|
res.status(404)
|
||||||
.json({ error: 'Video channel not found' })
|
.json({ error: 'Video channel not found' })
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Response } from 'express'
|
||||||
import { fetchVideo, VideoFetchType } from '../video'
|
import { fetchVideo, VideoFetchType } from '../video'
|
||||||
import { UserRight } from '../../../shared/models/users'
|
import { UserRight } from '../../../shared/models/users'
|
||||||
import { VideoChannelModel } from '../../models/video/video-channel'
|
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') {
|
async function doesVideoExist (id: number | string, res: Response, fetchType: VideoFetchType = 'all') {
|
||||||
const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined
|
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
|
break
|
||||||
|
|
||||||
case 'only-video':
|
case 'only-video':
|
||||||
res.locals.onlyVideo = video
|
res.locals.onlyVideo = video as MVideoThumbnail
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'only-video-with-rights':
|
case 'only-video-with-rights':
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import { VideoModel } from '../models/video/video'
|
import { VideoModel } from '../models/video/video'
|
||||||
import * as Bluebird from 'bluebird'
|
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'
|
import { Response } from 'express'
|
||||||
|
|
||||||
type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none'
|
type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none'
|
||||||
|
@ -30,10 +36,10 @@ function fetchVideo (
|
||||||
|
|
||||||
type VideoFetchByUrlType = 'all' | 'only-video'
|
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: 'only-video'): 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<MVideoAccountAllFiles> | Bluebird<MVideoThumbnail> {
|
function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail> {
|
||||||
if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url)
|
if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url)
|
||||||
|
|
||||||
if (fetchType === 'only-video') return VideoModel.loadByUrl(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
|
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 {
|
export {
|
||||||
VideoFetchType,
|
VideoFetchType,
|
||||||
VideoFetchByUrlType,
|
VideoFetchByUrlType,
|
||||||
fetchVideo,
|
fetchVideo,
|
||||||
getVideo,
|
getVideo,
|
||||||
|
getVideoWithAttributes,
|
||||||
fetchVideoByUrl
|
fetchVideoByUrl
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,15 +24,17 @@ import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor'
|
||||||
import { sequelizeTypescript } from '../../initializers/database'
|
import { sequelizeTypescript } from '../../initializers/database'
|
||||||
import {
|
import {
|
||||||
MAccount,
|
MAccount,
|
||||||
|
MAccountDefault,
|
||||||
MActor,
|
MActor,
|
||||||
MActorAccountChannelId,
|
MActorAccountChannelId,
|
||||||
|
MActorAccountChannelIdActor,
|
||||||
MActorAccountId,
|
MActorAccountId,
|
||||||
MActorDefault,
|
MActorDefault,
|
||||||
MActorFull,
|
MActorFull,
|
||||||
|
MActorFullActor,
|
||||||
MActorId,
|
MActorId,
|
||||||
MActorAccountChannelIdActor,
|
|
||||||
MChannel,
|
MChannel,
|
||||||
MActorFullActor, MAccountActorDefault, MChannelActorDefault, MChannelActorAccountDefault
|
MChannelAccountDefault
|
||||||
} from '../../typings/models'
|
} from '../../typings/models'
|
||||||
|
|
||||||
// Set account keys, this could be long so process after the account creation and do not block the client
|
// 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') {
|
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
|
actorCreated.Account.Actor = actorCreated
|
||||||
} else if (actorCreated.type === 'Group') { // Video channel
|
} else if (actorCreated.type === 'Group') { // Video channel
|
||||||
actorCreated.VideoChannel = await saveVideoChannel(actorCreated, result, ownerActor, t) as MChannelActorAccountDefault
|
const channel = await saveVideoChannel(actorCreated, result, ownerActor, t)
|
||||||
actorCreated.VideoChannel.Actor = actorCreated
|
actorCreated.VideoChannel = Object.assign(channel, { Actor: actorCreated, Account: ownerActor.Account })
|
||||||
actorCreated.VideoChannel.Account = ownerActor.Account
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actorCreated.Server = server
|
actorCreated.Server = server
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { getOrCreateVideoAndAccountAndChannel } from '../videos'
|
||||||
import { Notifier } from '../../notifier'
|
import { Notifier } from '../../notifier'
|
||||||
import { logger } from '../../../helpers/logger'
|
import { logger } from '../../../helpers/logger'
|
||||||
import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
|
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>) {
|
async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) {
|
||||||
const { activity, byActor: actorAnnouncer } = options
|
const { activity, byActor: actorAnnouncer } = options
|
||||||
|
@ -28,7 +28,7 @@ export {
|
||||||
async function processVideoShare (actorAnnouncer: MActorSignature, activity: ActivityAnnounce, notify: boolean) {
|
async function processVideoShare (actorAnnouncer: MActorSignature, activity: ActivityAnnounce, notify: boolean) {
|
||||||
const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id
|
const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id
|
||||||
|
|
||||||
let video: MVideoAccountAllFiles
|
let video: MVideoAccountLightBlacklistAllFiles
|
||||||
let videoCreated: boolean
|
let videoCreated: boolean
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { Notifier } from '../../notifier'
|
||||||
import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
|
import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
|
||||||
import { createOrUpdateVideoPlaylist } from '../playlist'
|
import { createOrUpdateVideoPlaylist } from '../playlist'
|
||||||
import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
|
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>) {
|
async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) {
|
||||||
const { activity, byActor } = options
|
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)
|
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 created: boolean
|
||||||
let comment: MCommentOwnerVideo
|
let comment: MCommentOwnerVideo
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { getOrCreateActorAndServerAndModel } from './actor'
|
||||||
import { getOrCreateVideoAndAccountAndChannel } from './videos'
|
import { getOrCreateVideoAndAccountAndChannel } from './videos'
|
||||||
import * as Bluebird from 'bluebird'
|
import * as Bluebird from 'bluebird'
|
||||||
import { checkUrlsSameHost } from '../../helpers/activitypub'
|
import { checkUrlsSameHost } from '../../helpers/activitypub'
|
||||||
import { MCommentOwner, MCommentOwnerVideo, MVideoAccountAllFiles } from '../../typings/models/video'
|
import { MCommentOwner, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../typings/models/video'
|
||||||
|
|
||||||
type ResolveThreadParams = {
|
type ResolveThreadParams = {
|
||||||
url: string,
|
url: string,
|
||||||
|
@ -15,7 +15,7 @@ type ResolveThreadParams = {
|
||||||
isVideo?: boolean,
|
isVideo?: boolean,
|
||||||
commentCreated?: 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[]) {
|
async function addVideoComments (commentUrls: string[]) {
|
||||||
return Bluebird.map(commentUrls, commentUrl => {
|
return Bluebird.map(commentUrls, commentUrl => {
|
||||||
|
|
|
@ -58,7 +58,7 @@ import {
|
||||||
MChannelDefault,
|
MChannelDefault,
|
||||||
MChannelId,
|
MChannelId,
|
||||||
MVideo,
|
MVideo,
|
||||||
MVideoAccountAllFiles,
|
MVideoAccountLightBlacklistAllFiles,
|
||||||
MVideoAccountLight,
|
MVideoAccountLight,
|
||||||
MVideoAP,
|
MVideoAP,
|
||||||
MVideoAPWithoutCaption,
|
MVideoAPWithoutCaption,
|
||||||
|
@ -213,19 +213,19 @@ function getOrCreateVideoAndAccountAndChannel (options: {
|
||||||
syncParam?: SyncParam,
|
syncParam?: SyncParam,
|
||||||
fetchType?: 'all',
|
fetchType?: 'all',
|
||||||
allowRefresh?: boolean
|
allowRefresh?: boolean
|
||||||
}): Promise<{ video: MVideoAccountAllFiles, created: boolean, autoBlacklisted?: boolean }>
|
}): Promise<{ video: MVideoAccountLightBlacklistAllFiles, created: boolean, autoBlacklisted?: boolean }>
|
||||||
function getOrCreateVideoAndAccountAndChannel (options: {
|
function getOrCreateVideoAndAccountAndChannel (options: {
|
||||||
videoObject: { id: string } | string,
|
videoObject: { id: string } | string,
|
||||||
syncParam?: SyncParam,
|
syncParam?: SyncParam,
|
||||||
fetchType?: VideoFetchByUrlType,
|
fetchType?: VideoFetchByUrlType,
|
||||||
allowRefresh?: boolean
|
allowRefresh?: boolean
|
||||||
}): Promise<{ video: MVideoAccountAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }>
|
}): Promise<{ video: MVideoAccountLightBlacklistAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }>
|
||||||
async function getOrCreateVideoAndAccountAndChannel (options: {
|
async function getOrCreateVideoAndAccountAndChannel (options: {
|
||||||
videoObject: { id: string } | string,
|
videoObject: { id: string } | string,
|
||||||
syncParam?: SyncParam,
|
syncParam?: SyncParam,
|
||||||
fetchType?: VideoFetchByUrlType,
|
fetchType?: VideoFetchByUrlType,
|
||||||
allowRefresh?: boolean // true by default
|
allowRefresh?: boolean // true by default
|
||||||
}): Promise<{ video: MVideoAccountAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> {
|
}): Promise<{ video: MVideoAccountLightBlacklistAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> {
|
||||||
// Default params
|
// Default params
|
||||||
const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false }
|
const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false }
|
||||||
const fetchType = options.fetchType || 'all'
|
const fetchType = options.fetchType || 'all'
|
||||||
|
@ -263,7 +263,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateVideoFromAP (options: {
|
async function updateVideoFromAP (options: {
|
||||||
video: MVideoAccountAllFiles,
|
video: MVideoAccountLightBlacklistAllFiles,
|
||||||
videoObject: VideoTorrentObject,
|
videoObject: VideoTorrentObject,
|
||||||
account: MAccountActor,
|
account: MAccountActor,
|
||||||
channel: MChannelDefault,
|
channel: MChannelDefault,
|
||||||
|
@ -420,7 +420,7 @@ async function refreshVideoIfNeeded (options: {
|
||||||
|
|
||||||
// We need more attributes if the argument video was fetched with not enough joints
|
// We need more attributes if the argument video was fetched with not enough joints
|
||||||
const video = options.fetchedType === 'all'
|
const video = options.fetchedType === 'all'
|
||||||
? options.video as MVideoAccountAllFiles
|
? options.video as MVideoAccountLightBlacklistAllFiles
|
||||||
: await VideoModel.loadByUrlAndPopulateAccount(options.video.url)
|
: await VideoModel.loadByUrlAndPopulateAccount(options.video.url)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -11,11 +11,11 @@ import { sequelizeTypescript } from '../initializers/database'
|
||||||
import * as LRUCache from 'lru-cache'
|
import * as LRUCache from 'lru-cache'
|
||||||
import { queue } from 'async'
|
import { queue } from 'async'
|
||||||
import { downloadImage } from '../helpers/requests'
|
import { downloadImage } from '../helpers/requests'
|
||||||
import { MAccountActorDefault, MChannelActorDefault } from '../typings/models'
|
import { MAccountDefault, MChannelDefault } from '../typings/models'
|
||||||
|
|
||||||
async function updateActorAvatarFile (
|
async function updateActorAvatarFile (
|
||||||
avatarPhysicalFile: Express.Multer.File,
|
avatarPhysicalFile: Express.Multer.File,
|
||||||
accountOrChannel: MAccountActorDefault | MChannelActorDefault
|
accountOrChannel: MAccountDefault | MChannelDefault
|
||||||
) {
|
) {
|
||||||
const extension = extname(avatarPhysicalFile.filename)
|
const extension = extname(avatarPhysicalFile.filename)
|
||||||
const avatarName = uuidv4() + extension
|
const avatarName = uuidv4() + extension
|
||||||
|
|
|
@ -2,14 +2,12 @@ import { createTransport, Transporter } from 'nodemailer'
|
||||||
import { isTestInstance } from '../helpers/core-utils'
|
import { isTestInstance } from '../helpers/core-utils'
|
||||||
import { bunyanLogger, logger } from '../helpers/logger'
|
import { bunyanLogger, logger } from '../helpers/logger'
|
||||||
import { CONFIG } from '../initializers/config'
|
import { CONFIG } from '../initializers/config'
|
||||||
import { UserModel } from '../models/account/user'
|
|
||||||
import { JobQueue } from './job-queue'
|
import { JobQueue } from './job-queue'
|
||||||
import { EmailPayload } from './job-queue/handlers/email'
|
import { EmailPayload } from './job-queue/handlers/email'
|
||||||
import { readFileSync } from 'fs-extra'
|
import { readFileSync } from 'fs-extra'
|
||||||
import { VideoBlacklistModel } from '../models/video/video-blacklist'
|
|
||||||
import { WEBSERVER } from '../initializers/constants'
|
import { WEBSERVER } from '../initializers/constants'
|
||||||
import { MCommentOwnerVideo, MVideo, MVideoAbuseVideo, MVideoAccountLight, MVideoBlacklistVideo } from '../typings/models/video'
|
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'
|
import { MVideoImport, MVideoImportVideo } from '@server/typings/models/video/video-import'
|
||||||
|
|
||||||
type SendEmailOptions = {
|
type SendEmailOptions = {
|
||||||
|
@ -109,7 +107,7 @@ class Emailer {
|
||||||
return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
|
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 followerName = actorFollow.ActorFollower.Account.getDisplayName()
|
||||||
const followingName = (actorFollow.ActorFollowing.VideoChannel || actorFollow.ActorFollowing.Account).getDisplayName()
|
const followingName = (actorFollow.ActorFollowing.VideoChannel || actorFollow.ActorFollowing.Account).getDisplayName()
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
|
||||||
import { ActorModel } from '../../../models/activitypub/actor'
|
import { ActorModel } from '../../../models/activitypub/actor'
|
||||||
import { Notifier } from '../../notifier'
|
import { Notifier } from '../../notifier'
|
||||||
import { sequelizeTypescript } from '../../../initializers/database'
|
import { sequelizeTypescript } from '../../../initializers/database'
|
||||||
import { MActorFollowFull, MActorFull } from '../../../typings/models'
|
import { MAccount, MActor, MActorFollowActors, MActorFollowFull, MActorFull } from '../../../typings/models'
|
||||||
|
|
||||||
export type ActivitypubFollowPayload = {
|
export type ActivitypubFollowPayload = {
|
||||||
followerActorId: number
|
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) {
|
if (fromActor.id === targetActor.id) {
|
||||||
throw new Error('Follower is the same than target actor.')
|
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 state = !fromActor.serverId && !targetActor.serverId ? 'accepted' : 'pending'
|
||||||
|
|
||||||
const actorFollow = await sequelizeTypescript.transaction(async t => {
|
const actorFollow = await sequelizeTypescript.transaction(async t => {
|
||||||
const [ actorFollow ] = await ActorFollowModel.findOrCreate<MActorFollowFull>({
|
const [ actorFollow ] = await ActorFollowModel.findOrCreate<MActorFollowActors>({
|
||||||
where: {
|
where: {
|
||||||
actorId: fromActor.id,
|
actorId: fromActor.id,
|
||||||
targetActorId: targetActor.id
|
targetActorId: targetActor.id
|
||||||
|
@ -75,5 +75,14 @@ async function follow (fromActor: MActorFull, targetActor: MActorFull) {
|
||||||
return actorFollow
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,13 +111,11 @@ type ProcessFileOptions = {
|
||||||
generateThumbnail: boolean
|
generateThumbnail: boolean
|
||||||
generatePreview: 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 tempVideoPath: string
|
||||||
let videoDestFile: string
|
let videoDestFile: string
|
||||||
let videoFile: VideoFileModel
|
let videoFile: VideoFileModel
|
||||||
|
|
||||||
const videoImport = videoImportArg as MVideoImportDefaultFiles
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Download video from youtubeDL
|
// Download video from youtubeDL
|
||||||
tempVideoPath = await downloader()
|
tempVideoPath = await downloader()
|
||||||
|
@ -142,35 +140,37 @@ async function processFile (downloader: () => Promise<string>, videoImportArg: M
|
||||||
videoId: videoImport.videoId
|
videoId: videoImport.videoId
|
||||||
}
|
}
|
||||||
videoFile = new VideoFileModel(videoFileData)
|
videoFile = new VideoFileModel(videoFileData)
|
||||||
|
|
||||||
|
const videoWithFiles = Object.assign(videoImport.Video, { VideoFiles: [ videoFile ] })
|
||||||
// To clean files if the import fails
|
// To clean files if the import fails
|
||||||
videoImport.Video.VideoFiles = [ videoFile ]
|
const videoImportWithFiles: MVideoImportDefaultFiles = Object.assign(videoImport, { Video: videoWithFiles })
|
||||||
|
|
||||||
// Move file
|
// 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)
|
await move(tempVideoPath, videoDestFile)
|
||||||
tempVideoPath = null // This path is not used anymore
|
tempVideoPath = null // This path is not used anymore
|
||||||
|
|
||||||
// Process thumbnail
|
// Process thumbnail
|
||||||
let thumbnailModel: MThumbnail
|
let thumbnailModel: MThumbnail
|
||||||
if (options.downloadThumbnail && options.thumbnailUrl) {
|
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) {
|
} else if (options.generateThumbnail || options.downloadThumbnail) {
|
||||||
thumbnailModel = await generateVideoMiniature(videoImport.Video, videoFile, ThumbnailType.MINIATURE)
|
thumbnailModel = await generateVideoMiniature(videoImportWithFiles.Video, videoFile, ThumbnailType.MINIATURE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process preview
|
// Process preview
|
||||||
let previewModel: MThumbnail
|
let previewModel: MThumbnail
|
||||||
if (options.downloadPreview && options.thumbnailUrl) {
|
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) {
|
} else if (options.generatePreview || options.downloadPreview) {
|
||||||
previewModel = await generateVideoMiniature(videoImport.Video, videoFile, ThumbnailType.PREVIEW)
|
previewModel = await generateVideoMiniature(videoImportWithFiles.Video, videoFile, ThumbnailType.PREVIEW)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create torrent
|
// Create torrent
|
||||||
await videoImport.Video.createTorrentAndSetInfoHash(videoFile)
|
await videoImportWithFiles.Video.createTorrentAndSetInfoHash(videoFile)
|
||||||
|
|
||||||
const { videoImportUpdated, video } = await sequelizeTypescript.transaction(async t => {
|
const { videoImportUpdated, video } = await sequelizeTypescript.transaction(async t => {
|
||||||
const videoImportToUpdate = videoImport as MVideoImportVideo
|
const videoImportToUpdate = videoImportWithFiles as MVideoImportVideo
|
||||||
|
|
||||||
// Refresh video
|
// Refresh video
|
||||||
const video = await VideoModel.load(videoImportToUpdate.videoId, t)
|
const video = await VideoModel.load(videoImportToUpdate.videoId, t)
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {
|
||||||
MVideoFullLight
|
MVideoFullLight
|
||||||
} from '../typings/models/video'
|
} from '../typings/models/video'
|
||||||
import { MUser, MUserAccount, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/typings/models/user'
|
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 { ActorFollowModel } from '../models/activitypub/actor-follow'
|
||||||
import { MVideoImportVideo } from '@server/typings/models/video/video-import'
|
import { MVideoImportVideo } from '@server/typings/models/video/video-import'
|
||||||
import { AccountModel } from '@server/models/account/account'
|
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 }))
|
.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)
|
this.notifyUserOfNewActorFollow(actorFollow)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
logger.error(
|
logger.error(
|
||||||
|
@ -231,7 +231,7 @@ class Notifier {
|
||||||
return this.notify({ users, settingGetter, notificationCreator, emailSender })
|
return this.notify({ users, settingGetter, notificationCreator, emailSender })
|
||||||
}
|
}
|
||||||
|
|
||||||
private async notifyUserOfNewActorFollow (actorFollow: MActorFollowFull) {
|
private async notifyUserOfNewActorFollow (actorFollow: MActorFollowFollowingFullFollowerAccount) {
|
||||||
if (actorFollow.ActorFollowing.isOwned() === false) return
|
if (actorFollow.ActorFollowing.isOwned() === false) return
|
||||||
|
|
||||||
// Account follows one of our account?
|
// Account follows one of our account?
|
||||||
|
|
|
@ -32,7 +32,9 @@ type CandidateToDuplicate = {
|
||||||
streamingPlaylists: MStreamingPlaylist[]
|
streamingPlaylists: MStreamingPlaylist[]
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMVideoRedundancyFileVideo (o: MVideoRedundancyVideo): o is MVideoRedundancyFileVideo {
|
function isMVideoRedundancyFileVideo (
|
||||||
|
o: MVideoRedundancyFileVideo | MVideoRedundancyStreamingPlaylistVideo
|
||||||
|
): o is MVideoRedundancyFileVideo {
|
||||||
return !!(o as MVideoRedundancyFileVideo).VideoFile
|
return !!(o as MVideoRedundancyFileVideo).VideoFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ import { isActorPreferredUsernameValid } from '../../../helpers/custom-validator
|
||||||
import { ActorModel } from '../../../models/activitypub/actor'
|
import { ActorModel } from '../../../models/activitypub/actor'
|
||||||
import { isBooleanValid } from '../../../helpers/custom-validators/misc'
|
import { isBooleanValid } from '../../../helpers/custom-validators/misc'
|
||||||
import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares'
|
import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares'
|
||||||
import { MChannelActorAccountDefault } from '../../../typings/models/video'
|
import { MChannelAccountDefault, MUser } from '@server/typings/models'
|
||||||
import { MUser } from '@server/typings/models'
|
|
||||||
|
|
||||||
const videoChannelsAddValidator = [
|
const videoChannelsAddValidator = [
|
||||||
body('name').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'),
|
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) {
|
if (videoChannel.Actor.isOwned() === false) {
|
||||||
res.status(403)
|
res.status(403)
|
||||||
.json({ error: 'Cannot remove video channel of another server.' })
|
.json({ error: 'Cannot remove video channel of another server.' })
|
||||||
|
|
|
@ -44,7 +44,7 @@ import { isLocalVideoAccepted } from '../../../lib/moderation'
|
||||||
import { Hooks } from '../../../lib/plugins/hooks'
|
import { Hooks } from '../../../lib/plugins/hooks'
|
||||||
import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../../../helpers/middlewares'
|
import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../../../helpers/middlewares'
|
||||||
import { MVideoFullLight } from '@server/typings/models'
|
import { MVideoFullLight } from '@server/typings/models'
|
||||||
import { getVideo } from '../../../helpers/video'
|
import { getVideoWithAttributes } from '../../../helpers/video'
|
||||||
|
|
||||||
const videosAddValidator = getCommonVideoEditAttributes().concat([
|
const videosAddValidator = getCommonVideoEditAttributes().concat([
|
||||||
body('videofile')
|
body('videofile')
|
||||||
|
@ -123,7 +123,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
|
||||||
])
|
])
|
||||||
|
|
||||||
async function checkVideoFollowConstraints (req: express.Request, res: express.Response, next: express.NextFunction) {
|
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
|
// Anybody can watch local videos
|
||||||
if (video.isOwned() === true) return next()
|
if (video.isOwned() === true) return next()
|
||||||
|
@ -157,7 +157,7 @@ const videosCustomGetValidator = (fetchType: 'all' | 'only-video' | 'only-video-
|
||||||
if (areValidationErrors(req, res)) return
|
if (areValidationErrors(req, res)) return
|
||||||
if (!await doesVideoExist(req.params.id, res, fetchType)) return
|
if (!await doesVideoExist(req.params.id, res, fetchType)) return
|
||||||
|
|
||||||
const video = getVideo(res)
|
const video = getVideoWithAttributes(res)
|
||||||
const videoAll = video as MVideoFullLight
|
const videoAll = video as MVideoFullLight
|
||||||
|
|
||||||
// Video private or blacklisted
|
// Video private or blacklisted
|
||||||
|
|
|
@ -55,7 +55,7 @@ import { UserAdminFlag } from '../../../shared/models/users/user-flag.model'
|
||||||
import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
|
import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
|
||||||
import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
|
import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
|
||||||
import * as Bluebird from 'bluebird'
|
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 {
|
enum ScopeNames {
|
||||||
WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL'
|
WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL'
|
||||||
|
@ -384,7 +384,7 @@ export class UserModel extends Model<UserModel> {
|
||||||
return UserModel.findOne(query)
|
return UserModel.findOne(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadByUsernameAndPopulateChannels (username: string): Bluebird<MUserChannel> {
|
static loadByUsernameAndPopulateChannels (username: string): Bluebird<MUserNotifSettingChannelDefault> {
|
||||||
const query = {
|
const query = {
|
||||||
where: {
|
where: {
|
||||||
username: { [ Op.iLike ]: username }
|
username: { [ Op.iLike ]: username }
|
||||||
|
|
|
@ -37,7 +37,6 @@ import * as Bluebird from 'bluebird'
|
||||||
import {
|
import {
|
||||||
MChannelAccountDefault,
|
MChannelAccountDefault,
|
||||||
MChannelActor,
|
MChannelActor,
|
||||||
MChannelActorAccountDefault,
|
|
||||||
MChannelActorAccountDefaultVideos
|
MChannelActorAccountDefaultVideos
|
||||||
} from '../../typings/models/video'
|
} 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()
|
return VideoChannelModel.unscoped()
|
||||||
.scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
|
.scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
|
||||||
.findByPk(id)
|
.findByPk(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadByIdAndAccount (id: number, accountId: number): Bluebird<MChannelActorAccountDefault> {
|
static loadByIdAndAccount (id: number, accountId: number): Bluebird<MChannelAccountDefault> {
|
||||||
const query = {
|
const query = {
|
||||||
where: {
|
where: {
|
||||||
id,
|
id,
|
||||||
|
@ -395,7 +394,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
|
||||||
.findOne(query)
|
.findOne(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadAndPopulateAccount (id: number): Bluebird<MChannelActorAccountDefault> {
|
static loadAndPopulateAccount (id: number): Bluebird<MChannelAccountDefault> {
|
||||||
return VideoChannelModel.unscoped()
|
return VideoChannelModel.unscoped()
|
||||||
.scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
|
.scope([ ScopeNames.WITH_ACTOR, ScopeNames.WITH_ACCOUNT ])
|
||||||
.findByPk(id)
|
.findByPk(id)
|
||||||
|
@ -427,7 +426,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
|
||||||
return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host)
|
return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host)
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadLocalByNameAndPopulateAccount (name: string): Bluebird<MChannelActorAccountDefault> {
|
static loadLocalByNameAndPopulateAccount (name: string): Bluebird<MChannelAccountDefault> {
|
||||||
const query = {
|
const query = {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
|
@ -446,7 +445,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
|
||||||
.findOne(query)
|
.findOne(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
static loadByNameAndHostAndPopulateAccount (name: string, host: string): Bluebird<MChannelActorAccountDefault> {
|
static loadByNameAndHostAndPopulateAccount (name: string, host: string): Bluebird<MChannelAccountDefault> {
|
||||||
const query = {
|
const query = {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,18 +121,18 @@ import { createTorrentPromise } from '../../helpers/webtorrent'
|
||||||
import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
|
import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
|
||||||
import {
|
import {
|
||||||
MChannel,
|
MChannel,
|
||||||
MChannelActorAccountDefault,
|
MChannelAccountDefault,
|
||||||
MChannelId,
|
MChannelId,
|
||||||
MUserAccountId,
|
MUserAccountId,
|
||||||
MUserId,
|
MUserId,
|
||||||
MVideoAccountAllFiles,
|
|
||||||
MVideoAccountLight,
|
MVideoAccountLight,
|
||||||
|
MVideoAccountLightBlacklistAllFiles,
|
||||||
MVideoDetails,
|
MVideoDetails,
|
||||||
|
MVideoForUser,
|
||||||
MVideoFullLight,
|
MVideoFullLight,
|
||||||
MVideoIdThumbnail,
|
MVideoIdThumbnail,
|
||||||
MVideoThumbnail,
|
MVideoThumbnail,
|
||||||
MVideoWithAllFiles,
|
MVideoWithAllFiles,
|
||||||
MVideoWithBlacklistThumbnailScheduled,
|
|
||||||
MVideoWithRights
|
MVideoWithRights
|
||||||
} from '../../typings/models'
|
} from '../../typings/models'
|
||||||
import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'
|
import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'
|
||||||
|
@ -1015,7 +1015,7 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
AccountModel
|
AccountModel
|
||||||
],
|
],
|
||||||
transaction: options.transaction
|
transaction: options.transaction
|
||||||
}) as MChannelActorAccountDefault
|
}) as MChannelAccountDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
return sendDeleteVideo(instance, options.transaction)
|
return sendDeleteVideo(instance, options.transaction)
|
||||||
|
@ -1209,10 +1209,10 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
VideoModel.count(countQuery),
|
VideoModel.count(countQuery),
|
||||||
VideoModel.scope(findScopes).findAll(findQuery)
|
VideoModel.scope(findScopes).findAll<MVideoForUser>(findQuery)
|
||||||
]).then(([ count, rows ]) => {
|
]).then(([ count, rows ]) => {
|
||||||
return {
|
return {
|
||||||
data: rows as MVideoWithBlacklistThumbnailScheduled[],
|
data: rows,
|
||||||
total: count
|
total: count
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1468,7 +1468,7 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(query)
|
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 = {
|
const query: FindOptions = {
|
||||||
where: {
|
where: {
|
||||||
url
|
url
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
MActorFollowActorsDefault,
|
MActorFollowActorsDefault,
|
||||||
MActorFollowActorsDefaultSubscription,
|
MActorFollowActorsDefaultSubscription,
|
||||||
MActorFull,
|
MActorFull,
|
||||||
MChannelActorAccountDefault,
|
MChannelAccountDefault,
|
||||||
MComment,
|
MComment,
|
||||||
MCommentOwnerVideoReply,
|
MCommentOwnerVideoReply,
|
||||||
MUserDefault,
|
MUserDefault,
|
||||||
|
@ -53,7 +53,7 @@ declare module 'express' {
|
||||||
|
|
||||||
videoStreamingPlaylist?: MStreamingPlaylist
|
videoStreamingPlaylist?: MStreamingPlaylist
|
||||||
|
|
||||||
videoChannel?: MChannelActorAccountDefault
|
videoChannel?: MChannelAccountDefault
|
||||||
|
|
||||||
videoPlaylistFull?: MVideoPlaylistFull
|
videoPlaylistFull?: MVideoPlaylistFull
|
||||||
videoPlaylistSummary?: MVideoPlaylistFullSummary
|
videoPlaylistSummary?: MVideoPlaylistFullSummary
|
||||||
|
|
|
@ -2,10 +2,16 @@ import { AccountBlocklistModel } from '../../../models/account/account-blocklist
|
||||||
import { PickWith } from '../../utils'
|
import { PickWith } from '../../utils'
|
||||||
import { MAccountDefault } from './account'
|
import { MAccountDefault } from './account'
|
||||||
|
|
||||||
|
type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MAccountBlocklist = Omit<AccountBlocklistModel, 'ByAccount' | 'BlockedAccount'>
|
export type MAccountBlocklist = Omit<AccountBlocklistModel, 'ByAccount' | 'BlockedAccount'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'>
|
export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'>
|
||||||
|
|
||||||
export type MAccountBlocklistAccounts = MAccountBlocklist &
|
export type MAccountBlocklistAccounts = MAccountBlocklist &
|
||||||
PickWith<AccountBlocklistModel, 'ByAccount', MAccountDefault> &
|
Use<'ByAccount', MAccountDefault> &
|
||||||
PickWith<AccountBlocklistModel, 'BlockedAccount', MAccountDefault>
|
Use<'BlockedAccount', MAccountDefault>
|
||||||
|
|
|
@ -5,7 +5,8 @@ import {
|
||||||
MActorAPI,
|
MActorAPI,
|
||||||
MActorAudience,
|
MActorAudience,
|
||||||
MActorDefault,
|
MActorDefault,
|
||||||
MActorDefaultLight, MActorId,
|
MActorDefaultLight,
|
||||||
|
MActorId,
|
||||||
MActorServer,
|
MActorServer,
|
||||||
MActorSummary,
|
MActorSummary,
|
||||||
MActorUrl
|
MActorUrl
|
||||||
|
@ -14,43 +15,63 @@ import { PickWith } from '../../utils'
|
||||||
import { MAccountBlocklistId } from './account-blocklist'
|
import { MAccountBlocklistId } from './account-blocklist'
|
||||||
import { MChannelDefault } from '@server/typings/models'
|
import { MChannelDefault } from '@server/typings/models'
|
||||||
|
|
||||||
export type MAccountId = Pick<AccountModel, 'id'>
|
type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
|
||||||
export type MAccountIdActor = MAccountId &
|
|
||||||
PickWith<AccountModel, 'Actor', MActorAccountChannelId>
|
// ############################################################################
|
||||||
export type MAccountIdActorId = MAccountId &
|
|
||||||
PickWith<AccountModel, 'Actor', MActorId>
|
|
||||||
|
|
||||||
export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
|
export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
|
||||||
'VideoComments' | 'BlockedAccounts'>
|
'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 MAccountUserId = Pick<MAccount, 'userId'>
|
||||||
|
|
||||||
export type MAccountActor = MAccount &
|
// Only some Actor attributes
|
||||||
PickWith<AccountModel, 'Actor', MActor>
|
export type MAccountUrl = Use<'Actor', MActorUrl>
|
||||||
export type MAccountServer = MAccountActor &
|
export type MAccountAudience = Use<'Actor', MActorAudience>
|
||||||
PickWith<AccountModel, 'Actor', MActorServer>
|
|
||||||
|
|
||||||
export type MAccountActorDefault = MAccount &
|
export type MAccountIdActor = MAccountId &
|
||||||
PickWith<AccountModel, 'Actor', MActorDefault>
|
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'> &
|
export type MAccountSummary = Pick<MAccount, 'id' | 'name'> &
|
||||||
PickWith<AccountModel, 'Actor', MActorSummary>
|
Use<'Actor', MActorSummary>
|
||||||
|
|
||||||
export type MAccountBlocks = MAccountSummary &
|
export type MAccountSummaryBlocks = MAccountSummary &
|
||||||
PickWith<AccountModel, 'BlockedAccounts', MAccountBlocklistId[]>
|
Use<'BlockedAccounts', MAccountBlocklistId[]>
|
||||||
|
|
||||||
export type MAccountAPI = MAccountDefault &
|
export type MAccountAPI = MAccount &
|
||||||
PickWith<AccountModel, 'Actor', MActorAPI>
|
Use<'Actor', MActorAPI>
|
||||||
|
|
||||||
export type MAccountUrl = PickWith<AccountModel, 'Actor', MActorUrl>
|
|
||||||
export type MAccountAudience = PickWith<AccountModel, 'Actor', MActorAudience>
|
|
||||||
|
|
|
@ -1,27 +1,55 @@
|
||||||
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
|
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 { 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 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 &
|
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 &
|
export type MActorFollowSubscriptions = MActorFollow &
|
||||||
PickWith<ActorFollowModel, 'ActorFollowing', MActorChannelAccount>
|
Use<'ActorFollowing', MActorChannelAccountActor>
|
||||||
|
|
|
@ -1,74 +1,103 @@
|
||||||
import { ActorModel } from '../../../models/activitypub/actor'
|
import { ActorModel } from '../../../models/activitypub/actor'
|
||||||
import { PickWith } from '../../utils'
|
import { PickWith } from '../../utils'
|
||||||
import { MAccount, MAccountActorDefault, MAccountId, MAccountIdActor } from './account'
|
import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
|
||||||
import { MServerHost, MServerHostBlocks, MServer } from '../server'
|
import { MServer, MServerHost, MServerHostBlocks } from '../server'
|
||||||
import { MAvatar } from './avatar'
|
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 MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MActorUrl = Pick<MActor, 'url'>
|
export type MActorUrl = Pick<MActor, 'url'>
|
||||||
export type MActorId = Pick<MActor, 'id'>
|
export type MActorId = Pick<MActor, 'id'>
|
||||||
export type MActorUsername = Pick<MActor, 'preferredUsername'>
|
export type MActorUsername = Pick<MActor, 'preferredUsername'>
|
||||||
export type MActorHost = PickWith<ActorModel, 'Server', MServerHost>
|
|
||||||
|
|
||||||
export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
|
export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
|
||||||
export type MActorAudience = MActorUrl & MActorFollowersUrl
|
export type MActorAudience = MActorUrl & MActorFollowersUrl
|
||||||
|
export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
|
||||||
|
export type MActorSignature = MActorAccountChannelId
|
||||||
|
|
||||||
export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
|
export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
|
// Some association attributes
|
||||||
|
|
||||||
|
export type MActorHost = Use<'Server', MServerHost>
|
||||||
|
|
||||||
export type MActorDefaultLight = MActorLight &
|
export type MActorDefaultLight = MActorLight &
|
||||||
MActorHost &
|
Use<'Server', MServerHost> &
|
||||||
PickWith<ActorModel, 'Avatar', MAvatar>
|
Use<'Avatar', MAvatar>
|
||||||
|
|
||||||
export type MActorAccountId = MActor &
|
export type MActorAccountId = MActor &
|
||||||
PickWith<ActorModel, 'Account', MAccountId>
|
Use<'Account', MAccountId>
|
||||||
export type MActorAccountIdActor = MActor &
|
export type MActorAccountIdActor = MActor &
|
||||||
PickWith<ActorModel, 'Account', MAccountIdActor>
|
Use<'Account', MAccountIdActor>
|
||||||
|
|
||||||
export type MActorChannelId = MActor &
|
export type MActorChannelId = MActor &
|
||||||
PickWith<ActorModel, 'VideoChannel', MChannelId>
|
Use<'VideoChannel', MChannelId>
|
||||||
export type MActorChannelIdActor = MActor &
|
export type MActorChannelIdActor = MActor &
|
||||||
PickWith<ActorModel, 'VideoChannel', MChannelIdActor>
|
Use<'VideoChannel', MChannelIdActor>
|
||||||
|
|
||||||
export type MActorAccountChannelId = MActorAccountId & MActorChannelId
|
export type MActorAccountChannelId = MActorAccountId & MActorChannelId
|
||||||
export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
|
export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
|
// Include raw account/channel/server
|
||||||
|
|
||||||
export type MActorAccount = MActor &
|
export type MActorAccount = MActor &
|
||||||
PickWith<ActorModel, 'Account', MAccount>
|
Use<'Account', MAccount>
|
||||||
|
|
||||||
export type MActorChannel = MActor &
|
export type MActorChannel = MActor &
|
||||||
PickWith<ActorModel, 'VideoChannel', MChannel>
|
Use<'VideoChannel', MChannel>
|
||||||
|
|
||||||
export type MActorAccountChannel = MActorAccount & MActorChannel
|
export type MActorAccountChannel = MActorAccount & MActorChannel
|
||||||
|
|
||||||
export type MActorChannelAccount = MActor &
|
|
||||||
PickWith<ActorModel, 'VideoChannel', MChannelAccountActor>
|
|
||||||
|
|
||||||
export type MActorServer = MActor &
|
export type MActorServer = MActor &
|
||||||
PickWith<ActorModel, 'Server', MServer>
|
Use<'Server', MServer>
|
||||||
|
|
||||||
export type MActorDefault = MActorServer &
|
// ############################################################################
|
||||||
PickWith<ActorModel, 'Avatar', MAvatar>
|
|
||||||
|
|
||||||
export type MActorFull = MActorDefault &
|
// Complex actor associations
|
||||||
PickWith<ActorModel, 'Account', MAccount> &
|
|
||||||
PickWith<ActorModel, 'VideoChannel', MChannelAccountActor>
|
|
||||||
|
|
||||||
export type MActorFullActor = MActorDefault &
|
export type MActorDefault = MActor &
|
||||||
PickWith<ActorModel, 'Account', MAccountActorDefault> &
|
Use<'Server', MServer> &
|
||||||
PickWith<ActorModel, 'VideoChannel', MChannelActorAccountDefault>
|
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'> &
|
export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
|
||||||
MActorHost &
|
Use<'Server', MServerHost> &
|
||||||
PickWith<ActorModel, 'Avatar', MAvatar>
|
Use<'Avatar', MAvatar>
|
||||||
|
|
||||||
export type MActorSummaryBlocks = Omit<MActorSummary, 'Server'> &
|
export type MActorSummaryBlocks = MActorSummary &
|
||||||
PickWith<ActorModel, 'Server', MServerHostBlocks>
|
Use<'Server', MServerHostBlocks>
|
||||||
|
|
||||||
export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
|
|
||||||
|
|
||||||
export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
|
export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
|
||||||
'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
|
'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
|
||||||
|
|
||||||
export type MActorSignature = MActorAccountChannelId
|
|
||||||
|
|
1
server/typings/models/index.d.ts
vendored
1
server/typings/models/index.d.ts
vendored
|
@ -1,4 +1,5 @@
|
||||||
export * from './account'
|
export * from './account'
|
||||||
|
export * from './oauth'
|
||||||
export * from './server'
|
export * from './server'
|
||||||
export * from './user'
|
export * from './user'
|
||||||
export * from './video'
|
export * from './video'
|
||||||
|
|
2
server/typings/models/oauth/index.d.ts
vendored
Normal file
2
server/typings/models/oauth/index.d.ts
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './oauth-client'
|
||||||
|
export * from './oauth-token'
|
|
@ -2,8 +2,12 @@ import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
|
||||||
import { PickWith } from '@server/typings/utils'
|
import { PickWith } from '@server/typings/utils'
|
||||||
import { MUserAccountUrl } from '@server/typings/models'
|
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 MOAuthToken = Omit<OAuthTokenModel, 'User' | 'OAuthClients'>
|
||||||
|
|
||||||
export type MOAuthTokenUser = MOAuthToken &
|
export type MOAuthTokenUser = MOAuthToken &
|
||||||
PickWith<OAuthTokenModel, 'User', MUserAccountUrl> &
|
Use<'User', MUserAccountUrl> &
|
||||||
{ user?: MUserAccountUrl }
|
{ user?: MUserAccountUrl }
|
||||||
|
|
|
@ -2,8 +2,14 @@ import { ServerBlocklistModel } from '@server/models/server/server-blocklist'
|
||||||
import { PickWith } from '@server/typings/utils'
|
import { PickWith } from '@server/typings/utils'
|
||||||
import { MAccountDefault, MServer } from '@server/typings/models'
|
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 MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'BlockedServer'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MServerBlocklistAccountServer = MServerBlocklist &
|
export type MServerBlocklistAccountServer = MServerBlocklist &
|
||||||
PickWith<ServerBlocklistModel, 'ByAccount', MAccountDefault> &
|
Use<'ByAccount', MAccountDefault> &
|
||||||
PickWith<ServerBlocklistModel, 'BlockedServer', MServer>
|
Use<'BlockedServer', MServer>
|
||||||
|
|
|
@ -2,9 +2,15 @@ import { ServerModel } from '../../../models/server/server'
|
||||||
import { PickWith } from '../../utils'
|
import { PickWith } from '../../utils'
|
||||||
import { MAccountBlocklistId } from '../account'
|
import { MAccountBlocklistId } from '../account'
|
||||||
|
|
||||||
|
type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MServer = Omit<ServerModel, 'Actors' | 'BlockedByAccounts'>
|
export type MServer = Omit<ServerModel, 'Actors' | 'BlockedByAccounts'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MServerHost = Pick<MServer, 'host'>
|
export type MServerHost = Pick<MServer, 'host'>
|
||||||
|
|
||||||
export type MServerHostBlocks = MServerHost &
|
export type MServerHostBlocks = MServerHost &
|
||||||
PickWith<ServerModel, 'BlockedByAccounts', MAccountBlocklistId[]>
|
Use<'BlockedByAccounts', MAccountBlocklistId[]>
|
||||||
|
|
1
server/typings/models/user/index.d.ts
vendored
1
server/typings/models/user/index.d.ts
vendored
|
@ -1,3 +1,4 @@
|
||||||
export * from './user'
|
export * from './user'
|
||||||
export * from './user-notification'
|
export * from './user-notification'
|
||||||
|
export * from './user-notification-setting'
|
||||||
export * from './user-video-history'
|
export * from './user-video-history'
|
||||||
|
|
|
@ -12,6 +12,10 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
|
||||||
import { VideoImportModel } from '../../../models/video/video-import'
|
import { VideoImportModel } from '../../../models/video/video-import'
|
||||||
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
|
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
|
||||||
|
|
||||||
|
type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export namespace UserNotificationIncludes {
|
export namespace UserNotificationIncludes {
|
||||||
export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
|
export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
|
||||||
export type VideoIncludeChannel = VideoInclude &
|
export type VideoIncludeChannel = VideoInclude &
|
||||||
|
@ -56,14 +60,18 @@ export namespace UserNotificationIncludes {
|
||||||
PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
|
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'>
|
'VideoImport' | 'Account' | 'ActorFollow'>
|
||||||
|
|
||||||
export type UserNotificationModelForApi = UserNotificationModelOnly &
|
// ############################################################################
|
||||||
PickWith<UserNotificationModel, 'Video', UserNotificationIncludes.VideoIncludeChannel> &
|
|
||||||
PickWith<UserNotificationModel, 'Comment', UserNotificationIncludes.VideoCommentInclude> &
|
export type UserNotificationModelForApi = MUserNotification &
|
||||||
PickWith<UserNotificationModel, 'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
|
Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
|
||||||
PickWith<UserNotificationModel, 'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
|
Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
|
||||||
PickWith<UserNotificationModel, 'VideoImport', UserNotificationIncludes.VideoImportInclude> &
|
Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
|
||||||
PickWith<UserNotificationModel, 'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
|
Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
|
||||||
PickWith<UserNotificationModel, 'Account', UserNotificationIncludes.AccountIncludeActor>
|
Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
|
||||||
|
Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
|
||||||
|
Use<'Account', UserNotificationIncludes.AccountIncludeActor>
|
||||||
|
|
|
@ -3,30 +3,49 @@ import { PickWith } from '../../utils'
|
||||||
import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'
|
import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'
|
||||||
import { MNotificationSetting } from './user-notification-setting'
|
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 MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MUserId = Pick<UserModel, 'id'>
|
export type MUserId = Pick<UserModel, 'id'>
|
||||||
|
|
||||||
export type MUserWithNotificationSetting = MUser &
|
// ############################################################################
|
||||||
PickWith<UserModel, 'NotificationSetting', MNotificationSetting>
|
|
||||||
|
|
||||||
export type MUserAccountDefault = MUser &
|
// With account
|
||||||
PickWith<UserModel, 'Account', MAccountDefault>
|
|
||||||
|
|
||||||
export type MUserAccount = MUser &
|
|
||||||
PickWith<UserModel, 'Account', MAccount>
|
|
||||||
|
|
||||||
export type MUserAccountId = MUser &
|
export type MUserAccountId = MUser &
|
||||||
PickWith<UserModel, 'Account', MAccountId>
|
Use<'Account', MAccountId>
|
||||||
|
|
||||||
export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount
|
|
||||||
|
|
||||||
export type MUserDefault = MUser &
|
|
||||||
MUserWithNotificationSetting &
|
|
||||||
MUserAccountDefault
|
|
||||||
|
|
||||||
export type MUserChannel = MUserWithNotificationSetting &
|
|
||||||
PickWith<UserModel, 'Account', MAccountDefaultChannelDefault>
|
|
||||||
|
|
||||||
export type MUserAccountUrl = MUser &
|
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>
|
||||||
|
|
4
server/typings/models/video/index.d.ts
vendored
4
server/typings/models/video/index.d.ts
vendored
|
@ -5,10 +5,14 @@ export * from './video'
|
||||||
export * from './video-abuse'
|
export * from './video-abuse'
|
||||||
export * from './video-blacklist'
|
export * from './video-blacklist'
|
||||||
export * from './video-caption'
|
export * from './video-caption'
|
||||||
|
export * from './video-change-ownership'
|
||||||
export * from './video-channels'
|
export * from './video-channels'
|
||||||
export * from './video-comment'
|
export * from './video-comment'
|
||||||
export * from './video-file'
|
export * from './video-file'
|
||||||
|
export * from './video-import'
|
||||||
export * from './video-playlist'
|
export * from './video-playlist'
|
||||||
|
export * from './video-playlist-element'
|
||||||
|
export * from './video-rate'
|
||||||
export * from './video-redundancy'
|
export * from './video-redundancy'
|
||||||
export * from './video-share'
|
export * from './video-share'
|
||||||
export * from './video-streaming-playlist'
|
export * from './video-streaming-playlist'
|
||||||
|
|
|
@ -3,13 +3,21 @@ import { PickWith } from '../../utils'
|
||||||
import { MVideo } from './video'
|
import { MVideo } from './video'
|
||||||
import { MAccountDefault } from '../account'
|
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 MVideoAbuse = Omit<VideoAbuseModel, 'Account' | 'Video' | 'toActivityPubObject'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'>
|
export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'>
|
||||||
|
|
||||||
export type MVideoAbuseVideo = MVideoAbuse &
|
export type MVideoAbuseVideo = MVideoAbuse &
|
||||||
Pick<VideoAbuseModel, 'toActivityPubObject'> &
|
Pick<VideoAbuseModel, 'toActivityPubObject'> &
|
||||||
PickWith<VideoAbuseModel, 'Video', MVideo>
|
Use<'Video', MVideo>
|
||||||
|
|
||||||
export type MVideoAbuseAccountVideo = MVideoAbuseVideo &
|
export type MVideoAbuseAccountVideo = MVideoAbuse &
|
||||||
PickWith<VideoAbuseModel, 'Account', MAccountDefault>
|
Pick<VideoAbuseModel, 'toActivityPubObject'> &
|
||||||
|
Use<'Video', MVideo> &
|
||||||
|
Use<'Account', MAccountDefault>
|
||||||
|
|
|
@ -2,10 +2,16 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
|
||||||
import { PickWith } from '@server/typings/utils'
|
import { PickWith } from '@server/typings/utils'
|
||||||
import { MVideo } from '@server/typings/models'
|
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 MVideoBlacklist = Omit<VideoBlacklistModel, 'Video'>
|
||||||
|
|
||||||
export type MVideoBlacklistLight = Pick<MVideoBlacklist, 'id' | 'reason' | 'unfederated'>
|
export type MVideoBlacklistLight = Pick<MVideoBlacklist, 'id' | 'reason' | 'unfederated'>
|
||||||
export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'>
|
export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoBlacklistVideo = MVideoBlacklist &
|
export type MVideoBlacklistVideo = MVideoBlacklist &
|
||||||
PickWith<VideoBlacklistModel, 'Video', MVideo>
|
Use<'Video', MVideo>
|
||||||
|
|
|
@ -2,9 +2,15 @@ import { VideoCaptionModel } from '../../../models/video/video-caption'
|
||||||
import { PickWith } from '@server/typings/utils'
|
import { PickWith } from '@server/typings/utils'
|
||||||
import { VideoModel } from '@server/models/video/video'
|
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 MVideoCaption = Omit<VideoCaptionModel, 'Video'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'>
|
export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'>
|
||||||
|
|
||||||
export type MVideoCaptionVideo = MVideoCaption &
|
export type MVideoCaptionVideo = MVideoCaption &
|
||||||
PickWith<VideoCaptionModel, 'Video', Pick<VideoModel, 'id' | 'remote' | 'uuid'>>
|
Use<'Video', Pick<VideoModel, 'id' | 'remote' | 'uuid'>>
|
||||||
|
|
|
@ -2,9 +2,13 @@ import { VideoChangeOwnershipModel } from '@server/models/video/video-change-own
|
||||||
import { PickWith } from '@server/typings/utils'
|
import { PickWith } from '@server/typings/utils'
|
||||||
import { MAccountDefault, MVideoWithFileThumbnail } from '@server/typings/models'
|
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 MVideoChangeOwnership = Omit<VideoChangeOwnershipModel, 'Initiator' | 'NextOwner' | 'Video'>
|
||||||
|
|
||||||
export type MVideoChangeOwnershipFull = MVideoChangeOwnership &
|
export type MVideoChangeOwnershipFull = MVideoChangeOwnership &
|
||||||
PickWith<VideoChangeOwnershipModel, 'Initiator', MAccountDefault> &
|
Use<'Initiator', MAccountDefault> &
|
||||||
PickWith<VideoChangeOwnershipModel, 'NextOwner', MAccountDefault> &
|
Use<'NextOwner', MAccountDefault> &
|
||||||
PickWith<VideoChangeOwnershipModel, 'Video', MVideoWithFileThumbnail>
|
Use<'Video', MVideoWithFileThumbnail>
|
||||||
|
|
|
@ -1,70 +1,97 @@
|
||||||
import { FunctionProperties, PickWith } from '../../utils'
|
import { PickWith } from '../../utils'
|
||||||
import { VideoChannelModel } from '../../../models/video/video-channel'
|
import { VideoChannelModel } from '../../../models/video/video-channel'
|
||||||
import {
|
import {
|
||||||
MAccountActor,
|
MAccountActor,
|
||||||
MAccountAPI,
|
MAccountAPI,
|
||||||
MAccountBlocks,
|
|
||||||
MAccountDefault,
|
MAccountDefault,
|
||||||
MAccountLight,
|
MAccountLight,
|
||||||
|
MAccountSummaryBlocks,
|
||||||
MAccountUserId,
|
MAccountUserId,
|
||||||
MActor,
|
MActor,
|
||||||
MActorAccountChannelId,
|
MActorAccountChannelId,
|
||||||
MActorAPI,
|
MActorAPI,
|
||||||
MActorDefault,
|
MActorDefault,
|
||||||
MActorDefaultLight, MActorLight,
|
MActorDefaultLight,
|
||||||
|
MActorLight,
|
||||||
MActorSummary
|
MActorSummary
|
||||||
} from '../account'
|
} from '../account'
|
||||||
import { MVideo } from './video'
|
import { MVideo } from './video'
|
||||||
|
|
||||||
export type MChannelId = FunctionProperties<VideoChannelModel>
|
type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
|
||||||
export type MChannelIdActor = MChannelId &
|
|
||||||
PickWith<VideoChannelModel, 'Actor', MActorAccountChannelId>
|
// ############################################################################
|
||||||
|
|
||||||
export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
|
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'> &
|
export type MChannelUserId = Pick<MChannel, 'accountId'> &
|
||||||
PickWith<VideoChannelModel, 'Account', MAccountUserId>
|
Use<'Account', MAccountUserId>
|
||||||
|
|
||||||
|
export type MChannelActor = MChannel &
|
||||||
|
Use<'Actor', MActor>
|
||||||
|
|
||||||
// Default scope
|
// Default scope
|
||||||
export type MChannelDefault = MChannel &
|
export type MChannelDefault = MChannel &
|
||||||
PickWith<VideoChannelModel, 'Actor', MActorDefault>
|
Use<'Actor', MActorDefault>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
|
// Not all association attributes
|
||||||
|
|
||||||
export type MChannelLight = MChannel &
|
export type MChannelLight = MChannel &
|
||||||
PickWith<VideoChannelModel, 'Actor', MActorDefaultLight>
|
Use<'Actor', MActorDefaultLight>
|
||||||
|
|
||||||
|
export type MChannelActorLight = MChannel &
|
||||||
|
Use<'Actor', MActorLight>
|
||||||
|
|
||||||
export type MChannelAccountLight = MChannel &
|
export type MChannelAccountLight = MChannel &
|
||||||
PickWith<VideoChannelModel, 'Actor', MActorDefaultLight> &
|
Use<'Actor', MActorDefaultLight> &
|
||||||
PickWith<VideoChannelModel, 'Account', MAccountLight>
|
Use<'Account', MAccountLight>
|
||||||
|
|
||||||
export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
|
// ############################################################################
|
||||||
PickWith<VideoChannelModel, 'Actor', MActorSummary>
|
|
||||||
|
|
||||||
export type MChannelSummaryAccount = MChannelSummary &
|
// Account associations
|
||||||
PickWith<VideoChannelModel, 'Account', MAccountBlocks>
|
|
||||||
|
|
||||||
export type MChannelAPI = MChannel &
|
|
||||||
PickWith<VideoChannelModel, 'Actor', MActorAPI> &
|
|
||||||
PickWith<VideoChannelModel, 'Account', MAccountAPI>
|
|
||||||
|
|
||||||
export type MChannelAccountActor = MChannel &
|
export type MChannelAccountActor = MChannel &
|
||||||
PickWith<VideoChannelModel, 'Account', MAccountActor>
|
Use<'Account', MAccountActor>
|
||||||
export type MChannelAccountDefault = MChannelActor &
|
|
||||||
PickWith<VideoChannelModel, 'Account', MAccountDefault>
|
|
||||||
|
|
||||||
|
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 &
|
export type MChannelVideos = MChannel &
|
||||||
PickWith<VideoChannelModel, 'Videos', MVideo[]>
|
Use<'Videos', MVideo[]>
|
||||||
|
|
||||||
export type MChannelActor = MChannel &
|
export type MChannelActorAccountDefaultVideos = MChannel &
|
||||||
PickWith<VideoChannelModel, 'Actor', MActor>
|
Use<'Actor', MActorDefault> &
|
||||||
export type MChannelActorLight = MChannel &
|
Use<'Account', MAccountDefault> &
|
||||||
PickWith<VideoChannelModel, 'Actor', MActorLight>
|
Use<'Videos', MVideo[]>
|
||||||
export type MChannelActorDefault = MChannel &
|
|
||||||
PickWith<VideoChannelModel, 'Actor', MActorDefault>
|
|
||||||
|
|
||||||
export type MChannelActorAccountActor = MChannelAccountActor & MChannelActor
|
// ############################################################################
|
||||||
|
|
||||||
export type MChannelActorAccountDefault = MChannel &
|
// For API
|
||||||
PickWith<VideoChannelModel, 'Actor', MActorDefault> &
|
|
||||||
PickWith<VideoChannelModel, 'Account', MAccountDefault>
|
|
||||||
|
|
||||||
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>
|
||||||
|
|
|
@ -1,29 +1,43 @@
|
||||||
import { VideoCommentModel } from '../../../models/video/video-comment'
|
import { VideoCommentModel } from '../../../models/video/video-comment'
|
||||||
import { PickWith } from '../../utils'
|
import { PickWith } from '../../utils'
|
||||||
import { MAccountDefault } from '../account'
|
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 MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'>
|
||||||
export type MCommentId = Pick<MComment, 'id'>
|
export type MCommentId = Pick<MComment, 'id'>
|
||||||
|
|
||||||
export type MCommentAPI = MComment & { totalReplies: number }
|
// ############################################################################
|
||||||
|
|
||||||
export type MCommentOwner = MComment &
|
export type MCommentOwner = MComment &
|
||||||
PickWith<VideoCommentModel, 'Account', MAccountDefault>
|
Use<'Account', MAccountDefault>
|
||||||
|
|
||||||
export type MCommentVideo = MComment &
|
export type MCommentVideo = MComment &
|
||||||
PickWith<VideoCommentModel, 'Video', MVideoAccountLight>
|
Use<'Video', MVideoAccountLight>
|
||||||
|
|
||||||
export type MCommentReply = MComment &
|
export type MCommentReply = MComment &
|
||||||
PickWith<VideoCommentModel, 'InReplyToVideoComment', MComment>
|
Use<'InReplyToVideoComment', MComment>
|
||||||
|
|
||||||
export type MCommentOwnerReply = MCommentOwner & MCommentReply
|
export type MCommentOwnerVideo = MComment &
|
||||||
export type MCommentOwnerVideo = MCommentOwner & MCommentVideo
|
Use<'Account', MAccountDefault> &
|
||||||
export type MCommentReplyVideo = MCommentReply & MCommentVideo
|
Use<'Video', MVideoAccountLight>
|
||||||
export type MCommentOwnerVideoReply = MCommentOwnerVideo & MCommentReply
|
|
||||||
|
|
||||||
export type MCommentOwnerReplyVideoLight = MCommentOwnerReply &
|
export type MCommentOwnerVideoReply = MComment &
|
||||||
PickWith<VideoCommentModel, 'Video', MVideoIdUrl>
|
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 &
|
export type MCommentOwnerVideoFeed = MCommentOwner &
|
||||||
PickWith<VideoCommentModel, 'Video', MVideoFeed>
|
Use<'Video', MVideoFeed>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
|
export type MCommentAPI = MComment & { totalReplies: number }
|
||||||
|
|
|
@ -3,13 +3,17 @@ import { PickWith, PickWithOpt } from '../../utils'
|
||||||
import { MVideo, MVideoUUID } from './video'
|
import { MVideo, MVideoUUID } from './video'
|
||||||
import { MVideoRedundancyFileUrl } from './video-redundancy'
|
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 MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos'>
|
||||||
|
|
||||||
export type MVideoFileVideo = MVideoFile &
|
export type MVideoFileVideo = MVideoFile &
|
||||||
PickWith<VideoFileModel, 'Video', MVideo>
|
Use<'Video', MVideo>
|
||||||
|
|
||||||
export type MVideoFileVideoUUID = MVideoFile &
|
export type MVideoFileVideoUUID = MVideoFile &
|
||||||
PickWith<VideoFileModel, 'Video', MVideoUUID>
|
Use<'Video', MVideoUUID>
|
||||||
|
|
||||||
export type MVideoFileRedundanciesOpt = MVideoFile &
|
export type MVideoFileRedundanciesOpt = MVideoFile &
|
||||||
PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
|
PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
|
||||||
|
|
|
@ -2,14 +2,23 @@ import { VideoImportModel } from '@server/models/video/video-import'
|
||||||
import { PickWith } from '@server/typings/utils'
|
import { PickWith } from '@server/typings/utils'
|
||||||
import { MUser, MVideo, MVideoAccountLight, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models'
|
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 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 &
|
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>
|
||||||
|
|
|
@ -2,14 +2,27 @@ import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-e
|
||||||
import { PickWith } from '@server/typings/utils'
|
import { PickWith } from '@server/typings/utils'
|
||||||
import { MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models'
|
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 MVideoPlaylistElement = Omit<VideoPlaylistElementModel, 'VideoPlaylist' | 'Video'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoPlaylistElementId = Pick<MVideoPlaylistElement, 'id'>
|
export type MVideoPlaylistElementId = Pick<MVideoPlaylistElement, 'id'>
|
||||||
|
|
||||||
export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'videoId' | 'startTimestamp' | 'stopTimestamp'>
|
export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'videoId' | 'startTimestamp' | 'stopTimestamp'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement &
|
export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement &
|
||||||
PickWith<VideoPlaylistElementModel, 'Video', MVideoThumbnail>
|
Use<'Video', MVideoThumbnail>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
|
// For API
|
||||||
|
|
||||||
export type MVideoPlaylistAP = MVideoPlaylistElement &
|
export type MVideoPlaylistAP = MVideoPlaylistElement &
|
||||||
PickWith<VideoPlaylistElementModel, 'Video', MVideoUrl> &
|
Use<'Video', MVideoUrl> &
|
||||||
PickWith<VideoPlaylistElementModel, 'VideoPlaylist', MVideoPlaylistPrivacy>
|
Use<'VideoPlaylist', MVideoPlaylistPrivacy>
|
||||||
|
|
|
@ -5,38 +5,76 @@ import { MThumbnail } from './thumbnail'
|
||||||
import { MChannelDefault, MChannelSummary } from './video-channels'
|
import { MChannelDefault, MChannelSummary } from './video-channels'
|
||||||
import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element'
|
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 MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'>
|
export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'>
|
||||||
export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'>
|
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 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 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>
|
||||||
|
|
|
@ -2,11 +2,15 @@ import { AccountVideoRateModel } from '@server/models/account/account-video-rate
|
||||||
import { PickWith } from '@server/typings/utils'
|
import { PickWith } from '@server/typings/utils'
|
||||||
import { MAccountAudience, MAccountUrl, MVideo } from '..'
|
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 MAccountVideoRate = Omit<AccountVideoRateModel, 'Video' | 'Account'>
|
||||||
|
|
||||||
export type MAccountVideoRateAccountUrl = MAccountVideoRate &
|
export type MAccountVideoRateAccountUrl = MAccountVideoRate &
|
||||||
PickWith<AccountVideoRateModel, 'Account', MAccountUrl>
|
Use<'Account', MAccountUrl>
|
||||||
|
|
||||||
export type MAccountVideoRateAccountVideo = MAccountVideoRate &
|
export type MAccountVideoRateAccountVideo = MAccountVideoRate &
|
||||||
PickWith<AccountVideoRateModel, 'Account', MAccountAudience> &
|
Use<'Account', MAccountAudience> &
|
||||||
PickWith<AccountVideoRateModel, 'Video', MVideo>
|
Use<'Video', MVideo>
|
||||||
|
|
|
@ -2,17 +2,25 @@ import { VideoRedundancyModel } from '../../../models/redundancy/video-redundanc
|
||||||
import { PickWith } from '@server/typings/utils'
|
import { PickWith } from '@server/typings/utils'
|
||||||
import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo } from '@server/typings/models'
|
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 MVideoRedundancy = Omit<VideoRedundancyModel, 'VideoFile' | 'VideoStreamingPlaylist' | 'Actor'>
|
||||||
|
|
||||||
export type MVideoRedundancyFileUrl = Pick<MVideoRedundancy, 'fileUrl'>
|
export type MVideoRedundancyFileUrl = Pick<MVideoRedundancy, 'fileUrl'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoRedundancyFile = MVideoRedundancy &
|
export type MVideoRedundancyFile = MVideoRedundancy &
|
||||||
PickWith<VideoRedundancyModel, 'VideoFile', MVideoFile>
|
Use<'VideoFile', MVideoFile>
|
||||||
|
|
||||||
export type MVideoRedundancyFileVideo = MVideoRedundancy &
|
export type MVideoRedundancyFileVideo = MVideoRedundancy &
|
||||||
PickWith<VideoRedundancyModel, 'VideoFile', MVideoFileVideo>
|
Use<'VideoFile', MVideoFileVideo>
|
||||||
|
|
||||||
export type MVideoRedundancyStreamingPlaylistVideo = MVideoRedundancy &
|
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>
|
||||||
|
|
|
@ -3,10 +3,15 @@ import { PickWith } from '../../utils'
|
||||||
import { MActorDefault } from '../account'
|
import { MActorDefault } from '../account'
|
||||||
import { MVideo } from './video'
|
import { MVideo } from './video'
|
||||||
|
|
||||||
|
type Use<K extends keyof VideoShareModel, M> = PickWith<VideoShareModel, K, M>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoShare = Omit<VideoShareModel, 'Actor' | 'Video'>
|
export type MVideoShare = Omit<VideoShareModel, 'Actor' | 'Video'>
|
||||||
|
|
||||||
export type MVideoShareActor = MVideoShare &
|
export type MVideoShareActor = MVideoShare &
|
||||||
PickWith<VideoShareModel, 'Actor', MActorDefault>
|
Use<'Actor', MActorDefault>
|
||||||
|
|
||||||
export type MVideoShareFull = MVideoShareActor &
|
export type MVideoShareFull = MVideoShare &
|
||||||
PickWith<VideoShareModel, 'Video', MVideo>
|
Use<'Actor', MActorDefault> &
|
||||||
|
Use<'Video', MVideo>
|
||||||
|
|
|
@ -3,10 +3,14 @@ import { PickWith } from '../../utils'
|
||||||
import { MVideoRedundancyFileUrl } from './video-redundancy'
|
import { MVideoRedundancyFileUrl } from './video-redundancy'
|
||||||
import { MVideo } from '@server/typings/models'
|
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 MStreamingPlaylist = Omit<VideoStreamingPlaylistModel, 'Video' | 'RedundancyVideos'>
|
||||||
|
|
||||||
export type MStreamingPlaylistVideo = MStreamingPlaylist &
|
export type MStreamingPlaylistVideo = MStreamingPlaylist &
|
||||||
PickWith<VideoStreamingPlaylistModel, 'Video', MVideo>
|
Use<'Video', MVideo>
|
||||||
|
|
||||||
export type MStreamingPlaylistRedundancies = MStreamingPlaylist &
|
export type MStreamingPlaylistRedundancies = MStreamingPlaylist &
|
||||||
PickWith<VideoStreamingPlaylistModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
|
Use<'RedundancyVideos', MVideoRedundancyFileUrl[]>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { VideoModel } from '../../../models/video/video'
|
import { VideoModel } from '../../../models/video/video'
|
||||||
import { PickWith, PickWithOpt } from '../../utils'
|
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 { MTag } from './tag'
|
||||||
import { MVideoCaptionLanguage } from './video-caption'
|
import { MVideoCaptionLanguage } from './video-caption'
|
||||||
import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'
|
import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'
|
||||||
|
@ -10,10 +10,16 @@ import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blackl
|
||||||
import { MScheduleVideoUpdate } from './schedule-video-update'
|
import { MScheduleVideoUpdate } from './schedule-video-update'
|
||||||
import { MUserVideoHistoryTime } from '../user/user-video-history'
|
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' |
|
export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
|
||||||
'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
|
'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
|
||||||
'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
|
'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoId = Pick<MVideo, 'id'>
|
export type MVideoId = Pick<MVideo, 'id'>
|
||||||
export type MVideoUrl = Pick<MVideo, 'url'>
|
export type MVideoUrl = Pick<MVideo, 'url'>
|
||||||
export type MVideoUUID = Pick<MVideo, 'uuid'>
|
export type MVideoUUID = Pick<MVideo, 'uuid'>
|
||||||
|
@ -21,83 +27,120 @@ export type MVideoUUID = Pick<MVideo, 'uuid'>
|
||||||
export type MVideoIdUrl = MVideoId & MVideoUrl
|
export type MVideoIdUrl = MVideoId & MVideoUrl
|
||||||
export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
|
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 &
|
export type MVideoWithFile = MVideo &
|
||||||
PickWith<VideoModel, 'VideoFiles', MVideoFile[]>
|
Use<'VideoFiles', MVideoFile[]>
|
||||||
|
|
||||||
export type MVideoThumbnail = MVideo &
|
export type MVideoThumbnail = MVideo &
|
||||||
PickWith<VideoModel, 'Thumbnails', MThumbnail[]>
|
Use<'Thumbnails', MThumbnail[]>
|
||||||
export type MVideoIdThumbnail = MVideoThumbnail & MVideoId
|
|
||||||
|
export type MVideoIdThumbnail = MVideoId &
|
||||||
|
Use<'Thumbnails', MThumbnail[]>
|
||||||
|
|
||||||
|
export type MVideoWithFileThumbnail = MVideo &
|
||||||
|
Use<'VideoFiles', MVideoFile[]> &
|
||||||
|
Use<'Thumbnails', MThumbnail[]>
|
||||||
|
|
||||||
export type MVideoTag = MVideo &
|
export type MVideoTag = MVideo &
|
||||||
PickWith<VideoModel, 'Tags', MTag[]>
|
Use<'Tags', MTag[]>
|
||||||
|
|
||||||
export type MVideoWithSchedule = MVideo &
|
export type MVideoWithSchedule = MVideo &
|
||||||
PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
|
PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
|
||||||
|
|
||||||
export type MVideoWithFileThumbnail = MVideoWithFile & MVideoThumbnail
|
|
||||||
|
|
||||||
export type MVideoUser = MVideo &
|
|
||||||
PickWith<VideoModel, 'VideoChannel', MChannelUserId>
|
|
||||||
|
|
||||||
export type MVideoWithCaptions = MVideo &
|
export type MVideoWithCaptions = MVideo &
|
||||||
PickWith<VideoModel, 'VideoCaptions', MVideoCaptionLanguage[]>
|
Use<'VideoCaptions', MVideoCaptionLanguage[]>
|
||||||
|
|
||||||
export type MVideoWithBlacklistLight = MVideo &
|
|
||||||
PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistLight>
|
|
||||||
|
|
||||||
export type MVideoAccountLight = MVideo &
|
|
||||||
PickWith<VideoModel, 'VideoChannel', MChannelAccountLight>
|
|
||||||
|
|
||||||
export type MVideoWithRights = MVideoWithBlacklistLight & MVideoThumbnail & MVideoUser
|
|
||||||
|
|
||||||
export type MVideoWithStreamingPlaylist = MVideo &
|
export type MVideoWithStreamingPlaylist = MVideo &
|
||||||
PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylist[]>
|
Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
|
||||||
|
|
||||||
export type MVideoWithAllFiles = MVideoWithFileThumbnail & MVideoWithStreamingPlaylist
|
// ############################################################################
|
||||||
|
|
||||||
export type MVideoAccountAllFiles = MVideoWithAllFiles & MVideoAccountLight & MVideoWithBlacklistLight
|
// Associations with not all their attributes
|
||||||
export type MVideoAccountAllFilesCaptions = MVideoAccountAllFiles & MVideoWithCaptions
|
|
||||||
|
|
||||||
export type MVideoUserHistory = MVideo &
|
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 &
|
export type MVideoAccountDefault = MVideo &
|
||||||
PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault>
|
Use<'VideoChannel', MChannelAccountDefault>
|
||||||
|
|
||||||
export type MVideoThumbnailAccountDefault = MVideoThumbnail &
|
export type MVideoThumbnailAccountDefault = MVideo &
|
||||||
PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault>
|
Use<'Thumbnails', MThumbnail[]> &
|
||||||
|
Use<'VideoChannel', MChannelAccountDefault>
|
||||||
|
|
||||||
export type MVideoWithChannelActor = MVideo &
|
export type MVideoWithChannelActor = MVideo &
|
||||||
PickWith<VideoModel, 'VideoChannel', MChannelActor>
|
Use<'VideoChannel', MChannelActor>
|
||||||
|
|
||||||
export type MVideoFullLight = MVideoThumbnail &
|
export type MVideoFullLight = MVideo &
|
||||||
MVideoWithBlacklistLight &
|
Use<'Thumbnails', MThumbnail[]> &
|
||||||
MVideoTag &
|
Use<'VideoBlacklist', MVideoBlacklistLight> &
|
||||||
MVideoAccountLight &
|
Use<'Tags', MTag[]> &
|
||||||
MVideoUserHistory &
|
Use<'VideoChannel', MChannelAccountLight> &
|
||||||
MVideoWithFile &
|
Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
|
||||||
MVideoWithSchedule &
|
Use<'VideoFiles', MVideoFile[]> &
|
||||||
MVideoWithStreamingPlaylist &
|
Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
|
||||||
MVideoUserHistory
|
Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
|
||||||
|
|
||||||
|
// ############################################################################
|
||||||
|
|
||||||
|
// API
|
||||||
|
|
||||||
export type MVideoAP = MVideo &
|
export type MVideoAP = MVideo &
|
||||||
MVideoTag &
|
Use<'Tags', MTag[]> &
|
||||||
MVideoAccountLight &
|
Use<'VideoChannel', MChannelAccountLight> &
|
||||||
MVideoWithStreamingPlaylist &
|
Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
|
||||||
MVideoWithCaptions &
|
Use<'VideoCaptions', MVideoCaptionLanguage[]> &
|
||||||
PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistUnfederated> &
|
Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
|
||||||
PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]>
|
Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
|
||||||
|
|
||||||
export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
|
export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
|
||||||
|
|
||||||
export type MVideoDetails = MVideo &
|
export type MVideoDetails = MVideo &
|
||||||
MVideoWithBlacklistLight &
|
Use<'VideoBlacklist', MVideoBlacklistLight> &
|
||||||
MVideoTag &
|
Use<'Tags', MTag[]> &
|
||||||
MVideoAccountLight &
|
Use<'VideoChannel', MChannelAccountLight> &
|
||||||
MVideoWithSchedule &
|
Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
|
||||||
MVideoThumbnail &
|
Use<'Thumbnails', MThumbnail[]> &
|
||||||
MVideoUserHistory &
|
Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
|
||||||
PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
|
Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
|
||||||
PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]>
|
Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
|
||||||
|
|
||||||
|
export type MVideoForUser = MVideo &
|
||||||
|
Use<'VideoChannel', MChannelAccountDefault> &
|
||||||
|
Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
|
||||||
|
Use<'VideoBlacklist', MVideoBlacklistLight> &
|
||||||
|
Use<'Thumbnails', MThumbnail[]>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user