ActivityPub-federated video streaming platform using P2P directly in your web browser
Type toFormattedJSON
Chocobozzz1ca9f7c3f7af
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.tsindex e6b678f3a6..27351c1a95 100644--- a/server/controllers/api/users/index.ts+++ b/server/controllers/api/users/index.ts@@ -196,7 +196,7 @@ async function createUser (req: express.Request, res: express.Response) {videoQuota: body.videoQuota,videoQuotaDaily: body.videoQuotaDaily,adminFlags: body.adminFlags || UserAdminFlag.NONE- })+ }) as MUserconst { user, account } = await createUserAccountAndChannelAndPlaylist({ userToCreate: userToCreate })diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.tsindex af054f6206..78e1e7fa3f 100644--- a/server/controllers/api/users/me.ts+++ b/server/controllers/api/users/me.ts@@ -23,15 +23,12 @@ import { createReqFiles } from '../../../helpers/express-utils'import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model'import { updateAvatarValidator } from '../../../middlewares/validators/avatar'import { updateActorAvatarFile } from '../../../lib/avatar'-import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'import { VideoImportModel } from '../../../models/video/video-import'import { AccountModel } from '../../../models/account/account'import { CONFIG } from '../../../initializers/config'import { sequelizeTypescript } from '../../../initializers/database'import { sendVerifyUserEmail } from '../../../lib/user'-const auditLogger = auditLoggerFactory('users-me')-const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })const meRouter = express.Router()@@ -165,8 +162,6 @@ async function deleteMe (req: express.Request, res: express.Response) {await user.destroy()- auditLogger.delete(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON({})))-return res.sendStatus(204)}@@ -175,7 +170,6 @@ async function updateMe (req: express.Request, res: express.Response) {let sendVerificationEmail = falseconst user = res.locals.oauth.token.user- const oldUserAuditView = new UserAuditView(user.toFormattedJSON({}))if (body.password !== undefined) user.password = body.passwordif (body.nsfwPolicy !== undefined) user.nsfwPolicy = body.nsfwPolicy@@ -204,8 +198,6 @@ async function updateMe (req: express.Request, res: express.Response) {await userAccount.save({ transaction: t })await sendUpdateActor(userAccount, t)-- auditLogger.update(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON({})), oldUserAuditView)})if (sendVerificationEmail === true) {@@ -218,13 +210,10 @@ async function updateMe (req: express.Request, res: express.Response) {async function updateMyAvatar (req: express.Request, res: express.Response) {const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]const user = res.locals.oauth.token.user- const oldUserAuditView = new UserAuditView(user.toFormattedJSON({}))const userAccount = await AccountModel.load(user.Account.id)const avatar = await updateActorAvatarFile(avatarPhysicalFile, userAccount)- auditLogger.update(getAuditIdFromRes(res), new UserAuditView(user.toFormattedJSON({})), oldUserAuditView)-return res.json({ avatar: avatar.toFormattedJSON() })}diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.tsindex 2b6184a831..d4ca7a0afd 100644--- a/server/controllers/api/video-channel.ts+++ b/server/controllers/api/video-channel.ts@@ -19,7 +19,7 @@ import { VideoChannelModel } from '../../models/video/video-channel'import { videoChannelsNameWithHostValidator, videosSortValidator } from '../../middlewares/validators'import { sendUpdateActor } from '../../lib/activitypub/send'import { VideoChannelCreate, VideoChannelUpdate } from '../../../shared'-import { createVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel'+import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel'import { buildNSFWFilter, createReqFiles, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'import { setAsyncActorKeys } from '../../lib/activitypub'import { AccountModel } from '../../models/account/account'@@ -139,7 +139,7 @@ async function addVideoChannel (req: express.Request, res: express.Response) {const videoChannelCreated = await sequelizeTypescript.transaction(async t => {const account = await AccountModel.load(res.locals.oauth.token.User.Account.id, t)- return createVideoChannel(videoChannelInfo, account, t)+ return createLocalVideoChannel(videoChannelInfo, account, t)})setAsyncActorKeys(videoChannelCreated.Actor)diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.tsindex e7adcc35a2..8879f3442e 100644--- a/server/controllers/api/videos/import.ts+++ b/server/controllers/api/videos/import.ts@@ -1,6 +1,5 @@import * as express from 'express'import * as magnetUtil from 'magnet-uri'-import 'multer'import { auditLoggerFactory, getAuditIdFromRes, VideoImportAuditView } from '../../../helpers/audit-logger'import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'import { MIMETYPES } from '../../../initializers/constants'@@ -28,11 +27,12 @@ import {MChannelAccountDefault,MThumbnail,MUser,+ MVideoAccountDefault,MVideoTag,MVideoThumbnailAccountDefault,MVideoWithBlacklistLight} from '@server/typings/models'-import { MVideoImport, MVideoImportVideo } from '@server/typings/models/video/video-import'+import { MVideoImport, MVideoImportFormattable } from '@server/typings/models/video/video-import'const auditLogger = auditLoggerFactory('video-imports')const videoImportsRouter = express.Router()@@ -238,14 +238,14 @@ function insertIntoDB (parameters: {tags: string[],videoImportAttributes: Partial<MVideoImport>,user: MUser-}): Bluebird<MVideoImportVideo> {+}): Bluebird<MVideoImportFormattable> {const { video, thumbnailModel, previewModel, videoChannel, tags, videoImportAttributes, user } = parametersreturn sequelizeTypescript.transaction(async t => {const sequelizeOptions = { transaction: t }// Save video object in database- const videoCreated = await video.save(sequelizeOptions) as (MVideoThumbnailAccountDefault & MVideoWithBlacklistLight & MVideoTag)+ const videoCreated = await video.save(sequelizeOptions) as (MVideoAccountDefault & MVideoWithBlacklistLight & MVideoTag)videoCreated.VideoChannel = videoChannelif (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t)@@ -274,7 +274,7 @@ function insertIntoDB (parameters: {const videoImport = await VideoImportModel.create(Object.assign({ videoId: videoCreated.id }, videoImportAttributes),sequelizeOptions- ) as MVideoImportVideo+ ) as MVideoImportFormattablevideoImport.Video = videoCreatedreturn videoImportdiff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.tsindex 4f29058e54..2830ae0177 100644--- a/server/helpers/captions-utils.ts+++ b/server/helpers/captions-utils.ts@@ -2,9 +2,9 @@ import { join } from 'path'import { CONFIG } from '../initializers/config'import * as srt2vtt from 'srt-to-vtt'import { createReadStream, createWriteStream, move, remove } from 'fs-extra'-import { MVideoCaption } from '@server/typings/models'+import { MVideoCaptionFormattable } from '@server/typings/models'-async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaption) {+async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaptionFormattable) {const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIRconst destination = join(videoCaptionsDir, videoCaption.getCaptionName())diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.tsindex 5201bdeef3..13b73077e8 100644--- a/server/lib/activitypub/actor.ts+++ b/server/lib/activitypub/actor.ts@@ -38,7 +38,7 @@ import {} from '../../typings/models'// Set account keys, this could be long so process after the account creation and do not block the client-function setAsyncActorKeys (actor: MActor) {+function setAsyncActorKeys <T extends MActor> (actor: T) {return createPrivateAndPublicKeys().then(({ publicKey, privateKey }) => {actor.publicKey = publicKey@@ -148,7 +148,7 @@ function buildActorInstance (type: ActivityPubActorType, url: string, preferredUsharedInboxUrl: WEBSERVER.URL + '/inbox',followersUrl: url + '/followers',followingUrl: url + '/following'- })+ }) as MActor}async function updateActorInstance (actorInstance: ActorModel, attributes: ActivityPubActor) {diff --git a/server/lib/user.ts b/server/lib/user.tsindex 266974cace..d84aff464b 100644--- a/server/lib/user.ts+++ b/server/lib/user.ts@@ -2,9 +2,8 @@ import * as uuidv4 from 'uuid/v4'import { ActivityPubActorType } from '../../shared/models/activitypub'import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'import { AccountModel } from '../models/account/account'-import { UserModel } from '../models/account/user'import { buildActorInstance, getAccountActivityPubUrl, setAsyncActorKeys } from './activitypub'-import { createVideoChannel } from './video-channel'+import { createLocalVideoChannel } from './video-channel'import { ActorModel } from '../models/activitypub/actor'import { UserNotificationSettingModel } from '../models/account/user-notification-setting'import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users'@@ -13,17 +12,17 @@ import { sequelizeTypescript } from '../initializers/database'import { Transaction } from 'sequelize/types'import { Redis } from './redis'import { Emailer } from './emailer'-import { MAccountActor, MActor, MChannelActor } from '../typings/models'-import { MUser, MUserId, MUserNotifSettingAccount } from '../typings/models/user'+import { MAccountDefault, MActorDefault, MChannelActor } from '../typings/models'+import { MUser, MUserDefault, MUserId } from '../typings/models/user'type ChannelNames = { name: string, displayName: string }async function createUserAccountAndChannelAndPlaylist (parameters: {- userToCreate: UserModel,+ userToCreate: MUser,userDisplayName?: string,channelNames?: ChannelNames,validateUser?: boolean-}): Promise<{ user: MUserNotifSettingAccount, account: MAccountActor, videoChannel: MChannelActor }> {+}): Promise<{ user: MUserDefault, account: MAccountDefault, videoChannel: MChannelActor }> {const { userToCreate, userDisplayName, channelNames, validateUser = true } = parametersconst { user, account, videoChannel } = await sequelizeTypescript.transaction(async t => {@@ -32,7 +31,7 @@ async function createUserAccountAndChannelAndPlaylist (parameters: {validate: validateUser}- const userCreated: MUserNotifSettingAccount = await userToCreate.save(userOptions)+ const userCreated: MUserDefault = await userToCreate.save(userOptions)userCreated.NotificationSetting = await createDefaultUserNotificationSettings(userCreated, t)const accountCreated = await createLocalAccountWithoutKeys({@@ -45,7 +44,7 @@ async function createUserAccountAndChannelAndPlaylist (parameters: {userCreated.Account = accountCreatedconst channelAttributes = await buildChannelAttributes(userCreated, channelNames)- const videoChannel = await createVideoChannel(channelAttributes, accountCreated, t)+ const videoChannel = await createLocalVideoChannel(channelAttributes, accountCreated, t)const videoPlaylist = await createWatchLaterPlaylist(accountCreated, t)@@ -75,7 +74,7 @@ async function createLocalAccountWithoutKeys (parameters: {const url = getAccountActivityPubUrl(name)const actorInstance = buildActorInstance(type, url, name)- const actorInstanceCreated: MActor = await actorInstance.save({ transaction: t })+ const actorInstanceCreated: MActorDefault = await actorInstance.save({ transaction: t })const accountInstance = new AccountModel({name: displayName || name,@@ -84,7 +83,7 @@ async function createLocalAccountWithoutKeys (parameters: {actorId: actorInstanceCreated.id})- const accountInstanceCreated: MAccountActor = await accountInstance.save({ transaction: t })+ const accountInstanceCreated: MAccountDefault = await accountInstance.save({ transaction: t })accountInstanceCreated.Actor = actorInstanceCreatedreturn accountInstanceCreateddiff --git a/server/lib/video-channel.ts b/server/lib/video-channel.tsindex ee8eb65682..41eab456bb 100644--- a/server/lib/video-channel.ts+++ b/server/lib/video-channel.ts@@ -4,12 +4,12 @@ import { VideoChannelCreate } from '../../shared/models'import { VideoChannelModel } from '../models/video/video-channel'import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub'import { VideoModel } from '../models/video/video'-import { MAccountId, MChannelActor, MChannelId } from '../typings/models'+import { MAccountId, MChannelDefault, MChannelId } from '../typings/models'-type CustomVideoChannelModelAccount <T extends MAccountId> = MChannelActor &+type CustomVideoChannelModelAccount <T extends MAccountId> = MChannelDefault &{ Account?: T }-async function createVideoChannel <T extends MAccountId> (+async function createLocalVideoChannel <T extends MAccountId> (videoChannelInfo: VideoChannelCreate,account: T,t: Sequelize.Transaction@@ -31,7 +31,7 @@ async function createVideoChannel <T extends MAccountId> (const videoChannel = new VideoChannelModel(videoChannelData)const options = { transaction: t }- const videoChannelCreated: CustomVideoChannelModelAccount<T> = await videoChannel.save(options) as MChannelActor+ const videoChannelCreated: CustomVideoChannelModelAccount<T> = await videoChannel.save(options) as MChannelDefault// Do not forget to add Account/Actor information to the created video channelvideoChannelCreated.Account = account@@ -54,6 +54,6 @@ async function federateAllVideosOfChannel (videoChannel: MChannelId) {// ---------------------------------------------------------------------------export {- createVideoChannel,+ createLocalVideoChannel,federateAllVideosOfChannel}diff --git a/server/models/account/account-blocklist.ts b/server/models/account/account-blocklist.tsindex bb53713951..8bcaca8280 100644--- a/server/models/account/account-blocklist.ts+++ b/server/models/account/account-blocklist.ts@@ -4,7 +4,7 @@ import { getSort } from '../utils'import { AccountBlock } from '../../../shared/models/blocklist'import { Op } from 'sequelize'import * as Bluebird from 'bluebird'-import { MAccountBlocklist, MAccountBlocklistAccounts } from '@server/typings/models'+import { MAccountBlocklist, MAccountBlocklistAccounts, MAccountBlocklistFormattable } from '@server/typings/models'enum ScopeNames {WITH_ACCOUNTS = 'WITH_ACCOUNTS'@@ -134,7 +134,7 @@ export class AccountBlocklistModel extends Model<AccountBlocklistModel> {})}- toFormattedJSON (): AccountBlock {+ toFormattedJSON (this: MAccountBlocklistFormattable): AccountBlock {return {byAccount: this.ByAccount.toFormattedJSON(),blockedAccount: this.BlockedAccount.toFormattedJSON(),diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.tsindex 8b62dd05ff..a6edbeee8b 100644--- a/server/models/account/account-video-rate.ts+++ b/server/models/account/account-video-rate.ts@@ -11,7 +11,12 @@ import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypimport { AccountVideoRate } from '../../../shared'import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from '../video/video-channel'import * as Bluebird from 'bluebird'-import { MAccountVideoRate, MAccountVideoRateAccountUrl, MAccountVideoRateAccountVideo } from '@server/typings/models/video/video-rate'+import {+ MAccountVideoRate,+ MAccountVideoRateAccountUrl,+ MAccountVideoRateAccountVideo,+ MAccountVideoRateFormattable+} from '@server/typings/models/video/video-rate'/*Account rates per video.@@ -248,7 +253,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {})}- toFormattedJSON (): AccountVideoRate {+ toFormattedJSON (this: MAccountVideoRateFormattable): AccountVideoRate {return {video: this.Video.toFormattedJSON(),rating: this.typediff --git a/server/models/account/account.ts b/server/models/account/account.tsindex 4cc731075d..8369738b9c 100644--- a/server/models/account/account.ts+++ b/server/models/account/account.ts@@ -32,7 +32,7 @@ import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequimport { AccountBlocklistModel } from './account-blocklist'import { ServerBlocklistModel } from '../server/server-blocklist'import { ActorFollowModel } from '../activitypub/actor-follow'-import { MAccountActor, MAccountDefault } from '../../typings/models'+import { MAccountActor, MAccountDefault, MAccountSummaryFormattable, MAccountFormattable } from '../../typings/models'import * as Bluebird from 'bluebird'export enum ScopeNames {@@ -353,7 +353,7 @@ export class AccountModel extends Model<AccountModel> {.findAll(query)}- toFormattedJSON (): Account {+ toFormattedJSON (this: MAccountFormattable): Account {const actor = this.Actor.toFormattedJSON()const account = {id: this.id,@@ -367,8 +367,8 @@ export class AccountModel extends Model<AccountModel> {return Object.assign(actor, account)}- toFormattedSummaryJSON (): AccountSummary {- const actor = this.Actor.toFormattedJSON()+ toFormattedSummaryJSON (this: MAccountSummaryFormattable): AccountSummary {+ const actor = this.Actor.toFormattedSummaryJSON()return {id: this.id,diff --git a/server/models/account/user-notification-setting.ts b/server/models/account/user-notification-setting.tsindex c2fbc6d23c..1506295cf7 100644--- a/server/models/account/user-notification-setting.ts+++ b/server/models/account/user-notification-setting.ts@@ -17,6 +17,7 @@ import { UserModel } from './user'import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'import { UserNotificationSetting, UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'import { clearCacheByUserId } from '../../lib/oauth-model'+import { MNotificationSettingFormattable } from '@server/typings/models'@Table({tableName: 'userNotificationSetting',@@ -152,7 +153,7 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingMreturn clearCacheByUserId(instance.userId)}- toFormattedJSON (): UserNotificationSetting {+ toFormattedJSON (this: MNotificationSettingFormattable): UserNotificationSetting {return {newCommentOnMyVideo: this.newCommentOnMyVideo,newVideoFromSubscription: this.newVideoFromSubscription,diff --git a/server/models/account/user.ts b/server/models/account/user.tsindex cb54d79af3..616dd603ce 100644--- a/server/models/account/user.ts+++ b/server/models/account/user.ts@@ -55,7 +55,13 @@ import { UserAdminFlag } from '../../../shared/models/users/user-flag.model'import { isThemeNameValid } from '../../helpers/custom-validators/plugins'import { getThemeOrDefault } from '../../lib/plugins/theme-utils'import * as Bluebird from 'bluebird'-import { MUserNotifSettingChannelDefault, MUserDefault, MUserId, MUserWithNotificationSetting } from '@server/typings/models'+import {+ MUserDefault,+ MUserFormattable,+ MUserId,+ MUserNotifSettingChannelDefault,+ MUserWithNotificationSetting+} from '@server/typings/models'enum ScopeNames {WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL'@@ -554,7 +560,9 @@ export class UserModel extends Model<UserModel> {return comparePassword(password, this.password)}- toFormattedJSON (parameters: { withAdminFlags?: boolean } = {}): User {+ toSummaryJSON++ toFormattedJSON (this: MUserFormattable, parameters: { withAdminFlags?: boolean } = {}): User {const videoQuotaUsed = this.get('videoQuotaUsed')const videoQuotaUsedDaily = this.get('videoQuotaUsedDaily')diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.tsindex 8ef770cd49..c8b3aae9f2 100644--- a/server/models/activitypub/actor-follow.ts+++ b/server/models/activitypub/actor-follow.ts@@ -32,6 +32,7 @@ import {MActorFollowActorsDefault,MActorFollowActorsDefaultSubscription,MActorFollowFollowingHost,+ MActorFollowFormattable,MActorFollowSubscriptions} from '@server/typings/models'@@ -580,7 +581,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {return ActorFollowModel.findAll(query)}- toFormattedJSON (): ActorFollow {+ toFormattedJSON (this: MActorFollowFormattable): ActorFollow {const follower = this.ActorFollower.toFormattedJSON()const following = this.ActorFollowing.toFormattedJSON()diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.tsindex 2312127b42..e2213afa17 100644--- a/server/models/activitypub/actor.ts+++ b/server/models/activitypub/actor.ts@@ -36,7 +36,16 @@ import { isOutdated, throwIfNotValid } from '../utils'import { VideoChannelModel } from '../video/video-channel'import { ActorFollowModel } from './actor-follow'import { VideoModel } from '../video/video'-import { MActor, MActorAccountChannelId, MActorFull } from '../../typings/models'+import {+ MActor,+ MActorAccountChannelId,+ MActorFormattable,+ MActorFull, MActorHost,+ MActorServer,+ MActorSummaryFormattable,+ MServerHost,+ MActorRedundancyAllowed+} from '../../typings/models'import * as Bluebird from 'bluebird'enum ScopeNames {@@ -393,24 +402,31 @@ export class ActorModel extends Model<ActorModel> {})}- toFormattedJSON () {+ toFormattedSummaryJSON (this: MActorSummaryFormattable) {let avatar: Avatar = nullif (this.Avatar) {avatar = this.Avatar.toFormattedJSON()}return {- id: this.id,url: this.url,name: this.preferredUsername,host: this.getHost(),+ avatar+ }+ }++ toFormattedJSON (this: MActorFormattable) {+ const base = this.toFormattedSummaryJSON()++ return Object.assign(base, {+ id: this.id,hostRedundancyAllowed: this.getRedundancyAllowed(),followingCount: this.followingCount,followersCount: this.followersCount,- avatar,createdAt: this.createdAt,updatedAt: this.updatedAt- }+ })}toActivityPubObject (name: string, type: 'Account' | 'Application' | 'VideoChannel') {@@ -500,7 +516,7 @@ export class ActorModel extends Model<ActorModel> {return this.serverId === null}- getWebfingerUrl () {+ getWebfingerUrl (this: MActorServer) {return 'acct:' + this.preferredUsername + '@' + this.getHost()}@@ -508,11 +524,11 @@ export class ActorModel extends Model<ActorModel> {return this.Server ? `${this.preferredUsername}@${this.Server.host}` : this.preferredUsername}- getHost () {+ getHost (this: MActorHost) {return this.Server ? this.Server.host : WEBSERVER.HOST}- getRedundancyAllowed () {+ getRedundancyAllowed (this: MActorRedundancyAllowed) {return this.Server ? this.Server.redundancyAllowed : false}diff --git a/server/models/avatar/avatar.ts b/server/models/avatar/avatar.tsindex b401445929..950e4b1814 100644--- a/server/models/avatar/avatar.ts+++ b/server/models/avatar/avatar.ts@@ -7,6 +7,7 @@ import { remove } from 'fs-extra'import { CONFIG } from '../../initializers/config'import { throwIfNotValid } from '../utils'import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'+import { MAvatarFormattable } from '@server/typings/models'@Table({tableName: 'avatar',@@ -57,7 +58,7 @@ export class AvatarModel extends Model<AvatarModel> {return AvatarModel.findOne(query)}- toFormattedJSON (): Avatar {+ toFormattedJSON (this: MAvatarFormattable): Avatar {return {path: this.getStaticPath(),createdAt: this.createdAt,diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.tsindex debd25ea19..d094da1f56 100644--- a/server/models/server/plugin.ts+++ b/server/models/server/plugin.ts@@ -12,7 +12,7 @@ import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.mimport { FindAndCountOptions, json } from 'sequelize'import { RegisterServerSettingOptions } from '../../../shared/models/plugins/register-server-setting.model'import * as Bluebird from 'bluebird'-import { MPlugin } from '@server/typings/models'+import { MPlugin, MPluginFormattable } from '@server/typings/models'@DefaultScope(() => ({attributes: {@@ -253,7 +253,7 @@ export class PluginModel extends Model<PluginModel> {return result}- toFormattedJSON (): PeerTubePlugin {+ toFormattedJSON (this: MPluginFormattable): PeerTubePlugin {return {name: this.name,type: this.type,diff --git a/server/models/server/server-blocklist.ts b/server/models/server/server-blocklist.tsindex e4db93dfc5..3e96871911 100644--- a/server/models/server/server-blocklist.ts+++ b/server/models/server/server-blocklist.ts@@ -4,7 +4,7 @@ import { ServerModel } from './server'import { ServerBlock } from '../../../shared/models/blocklist'import { getSort } from '../utils'import * as Bluebird from 'bluebird'-import { MServerBlocklist, MServerBlocklistAccountServer } from '@server/typings/models'+import { MServerBlocklist, MServerBlocklistAccountServer, MServerBlocklistFormattable } from '@server/typings/models'enum ScopeNames {WITH_ACCOUNT = 'WITH_ACCOUNT',@@ -112,7 +112,7 @@ export class ServerBlocklistModel extends Model<ServerBlocklistModel> {})}- toFormattedJSON (): ServerBlock {+ toFormattedJSON (this: MServerBlocklistFormattable): ServerBlock {return {byAccount: this.ByAccount.toFormattedJSON(),blockedServer: this.BlockedServer.toFormattedJSON(),diff --git a/server/models/server/server.ts b/server/models/server/server.tsindex b0bdd2b0bc..3b6759b5c4 100644--- a/server/models/server/server.ts+++ b/server/models/server/server.ts@@ -4,7 +4,7 @@ import { ActorModel } from '../activitypub/actor'import { throwIfNotValid } from '../utils'import { ServerBlocklistModel } from './server-blocklist'import * as Bluebird from 'bluebird'-import { MServer } from '@server/typings/models/server'+import { MServer, MServerFormattable } from '@server/typings/models/server'@Table({tableName: 'server',@@ -65,7 +65,7 @@ export class ServerModel extends Model<ServerModel> {return this.BlockedByAccounts && this.BlockedByAccounts.length !== 0}- toFormattedJSON () {+ toFormattedJSON (this: MServerFormattable) {return {host: this.host}diff --git a/server/models/video/schedule-video-update.ts b/server/models/video/schedule-video-update.tsindex 603d556924..fc2a424aaa 100644--- a/server/models/video/schedule-video-update.ts+++ b/server/models/video/schedule-video-update.ts@@ -2,6 +2,7 @@ import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Taimport { ScopeNames as VideoScopeNames, VideoModel } from './video'import { VideoPrivacy } from '../../../shared/models/videos'import { Op, Transaction } from 'sequelize'+import { MScheduleVideoUpdateFormattable } from '@server/typings/models'@Table({tableName: 'scheduleVideoUpdate',@@ -96,7 +97,7 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> {return ScheduleVideoUpdateModel.destroy(query)}- toFormattedJSON () {+ toFormattedJSON (this: MScheduleVideoUpdateFormattable) {return {updateAt: this.updateAt,privacy: this.privacy || undefineddiff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.tsindex af7b40d11f..6ef1a915d8 100644--- a/server/models/video/video-abuse.ts+++ b/server/models/video/video-abuse.ts@@ -11,7 +11,7 @@ import { getSort, throwIfNotValid } from '../utils'import { VideoModel } from './video'import { VideoAbuseState } from '../../../shared'import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'-import { MVideoAbuse, MVideoAbuseAccountVideo, MVideoAbuseVideo } from '../../typings/models'+import { MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models'import * as Bluebird from 'bluebird'@Table({@@ -108,7 +108,7 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {})}- toFormattedJSON (this: MVideoAbuseAccountVideo): VideoAbuse {+ toFormattedJSON (this: MVideoAbuseFormattable): VideoAbuse {return {id: this.id,reason: this.reason,diff --git a/server/models/video/video-blacklist.ts b/server/models/video/video-blacklist.tsindex 5a0cac94a6..b4df6cd6a3 100644--- a/server/models/video/video-blacklist.ts+++ b/server/models/video/video-blacklist.ts@@ -8,7 +8,7 @@ import { CONSTRAINTS_FIELDS } from '../../initializers/constants'import { FindOptions } from 'sequelize'import { ThumbnailModel } from './thumbnail'import * as Bluebird from 'bluebird'-import { MVideoBlacklist } from '@server/typings/models'+import { MVideoBlacklist, MVideoBlacklistFormattable } from '@server/typings/models'@Table({tableName: 'videoBlacklist',@@ -111,7 +111,7 @@ export class VideoBlacklistModel extends Model<VideoBlacklistModel> {return VideoBlacklistModel.findOne(query)}- toFormattedJSON (): VideoBlacklist {+ toFormattedJSON (this: MVideoBlacklistFormattable): VideoBlacklist {return {id: this.id,createdAt: this.createdAt,diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.tsindex 9ce350d128..ad58017685 100644--- a/server/models/video/video-caption.ts+++ b/server/models/video/video-caption.ts@@ -22,7 +22,7 @@ import { logger } from '../../helpers/logger'import { remove } from 'fs-extra'import { CONFIG } from '../../initializers/config'import * as Bluebird from 'bluebird'-import { MVideoCaptionVideo } from '@server/typings/models'+import { MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/typings/models'export enum ScopeNames {WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE'@@ -154,7 +154,7 @@ export class VideoCaptionModel extends Model<VideoCaptionModel> {return this.Video.remote === false}- toFormattedJSON (): VideoCaption {+ toFormattedJSON (this: MVideoCaptionFormattable): VideoCaption {return {language: {id: this.language,@@ -164,15 +164,15 @@ export class VideoCaptionModel extends Model<VideoCaptionModel> {}}- getCaptionStaticPath () {+ getCaptionStaticPath (this: MVideoCaptionFormattable) {return join(LAZY_STATIC_PATHS.VIDEO_CAPTIONS, this.getCaptionName())}- getCaptionName () {+ getCaptionName (this: MVideoCaptionFormattable) {return `${this.Video.uuid}-${this.language}.vtt`}- removeCaptionFile () {+ removeCaptionFile (this: MVideoCaptionFormattable) {return remove(CONFIG.STORAGE.CAPTIONS_DIR + this.getCaptionName())}}diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.tsindex 2d0ff48fb2..f7a351329b 100644--- a/server/models/video/video-change-ownership.ts+++ b/server/models/video/video-change-ownership.ts@@ -3,7 +3,7 @@ import { AccountModel } from '../account/account'import { ScopeNames as VideoScopeNames, VideoModel } from './video'import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos'import { getSort } from '../utils'-import { MVideoChangeOwnershipFull } from '@server/typings/models/video/video-change-ownership'+import { MVideoChangeOwnershipFormattable, MVideoChangeOwnershipFull } from '@server/typings/models/video/video-change-ownership'import * as Bluebird from 'bluebird'enum ScopeNames {@@ -119,7 +119,7 @@ export class VideoChangeOwnershipModel extends Model<VideoChangeOwnershipModel>.findByPk(id)}- toFormattedJSON (): VideoChangeOwnership {+ toFormattedJSON (this: MVideoChangeOwnershipFormattable): VideoChangeOwnership {return {id: this.id,status: this.status,diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.tsindex b6a60827fa..7a4df516aa 100644--- a/server/models/video/video-channel.ts+++ b/server/models/video/video-channel.ts@@ -37,7 +37,7 @@ import * as Bluebird from 'bluebird'import {MChannelAccountDefault,MChannelActor,- MChannelActorAccountDefaultVideos+ MChannelActorAccountDefaultVideos, MChannelSummaryFormattable, MChannelFormattable} from '../../typings/models/video'// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation@@ -482,7 +482,20 @@ export class VideoChannelModel extends Model<VideoChannelModel> {.findByPk(id, options)}- toFormattedJSON (): VideoChannel {+ toFormattedSummaryJSON (this: MChannelSummaryFormattable): VideoChannelSummary {+ const actor = this.Actor.toFormattedSummaryJSON()++ return {+ id: this.id,+ name: actor.name,+ displayName: this.getDisplayName(),+ url: actor.url,+ host: actor.host,+ avatar: actor.avatar+ }+ }++ toFormattedJSON (this: MChannelFormattable): VideoChannel {const actor = this.Actor.toFormattedJSON()const videoChannel = {id: this.id,@@ -500,19 +513,6 @@ export class VideoChannelModel extends Model<VideoChannelModel> {return Object.assign(actor, videoChannel)}- toFormattedSummaryJSON (): VideoChannelSummary {- const actor = this.Actor.toFormattedJSON()-- return {- id: this.id,- name: actor.name,- displayName: this.getDisplayName(),- url: actor.url,- host: actor.host,- avatar: actor.avatar- }- }-toActivityPubObject (): ActivityPubActor {const obj = this.Actor.toActivityPubObject(this.name, 'VideoChannel')diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.tsindex c88dac1c19..84d71c553d 100644--- a/server/models/video/video-comment.ts+++ b/server/models/video/video-comment.ts@@ -17,6 +17,7 @@ import { FindOptions, Op, Order, ScopeOptions, Sequelize, Transaction } from 'seimport * as Bluebird from 'bluebird'import {MComment,+ MCommentFormattable,MCommentId,MCommentOwner,MCommentOwnerReplyVideoLight,@@ -475,7 +476,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {return uniq(result)}- toFormattedJSON () {+ toFormattedJSON (this: MCommentFormattable) {return {id: this.id,url: this.url,diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.tsindex 4e7eb5f0c7..6aa7c1e3ea 100644--- a/server/models/video/video-format-utils.ts+++ b/server/models/video/video-format-utils.ts@@ -16,7 +16,7 @@ import {} from '../../lib/activitypub'import { isArray } from '../../helpers/custom-validators/misc'import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model'-import { MVideo, MVideoAP, MVideoDetails } from '../../typings/models'+import { MVideo, MVideoAP, MVideoFormattable, MVideoFormattableDetails } from '../../typings/models'import { MStreamingPlaylistRedundancies } from '../../typings/models/video/video-streaming-playlist'import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'@@ -29,7 +29,7 @@ export type VideoFormattingJSONOptions = {blacklistInfo?: boolean}}-function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormattingJSONOptions): Video {+function videoModelToFormattedJSON (video: MVideoFormattable, options?: VideoFormattingJSONOptions): Video {const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefinedconst videoObject: Video = {@@ -103,7 +103,7 @@ function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormattingreturn videoObject}-function videoModelToFormattedDetailsJSON (video: MVideoDetails): VideoDetails {+function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): VideoDetails {const formattedJson = video.toFormattedJSON({additionalAttributes: {scheduledUpdate: true,diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.tsindex f596eea9d2..af5314ce9b 100644--- a/server/models/video/video-import.ts+++ b/server/models/video/video-import.ts@@ -21,7 +21,7 @@ import { VideoImport, VideoImportState } from '../../../shared'import { isVideoMagnetUriValid } from '../../helpers/custom-validators/videos'import { UserModel } from '../account/user'import * as Bluebird from 'bluebird'-import { MVideoImportDefault } from '@server/typings/models/video/video-import'+import { MVideoImportDefault, MVideoImportFormattable } from '@server/typings/models/video/video-import'@DefaultScope(() => ({include: [@@ -154,7 +154,7 @@ export class VideoImportModel extends Model<VideoImportModel> {return this.targetUrl || this.magnetUri || this.torrentName}- toFormattedJSON (): VideoImport {+ toFormattedJSON (this: MVideoImportFormattable): VideoImport {const videoFormatOptions = {completeDescription: true,additionalAttributes: { state: true, waitTranscoding: true, scheduledUpdate: true }diff --git a/server/models/video/video-playlist-element.ts b/server/models/video/video-playlist-element.tsindex 9011131619..80ca22a18f 100644--- a/server/models/video/video-playlist-element.ts+++ b/server/models/video/video-playlist-element.ts@@ -21,12 +21,16 @@ import { CONSTRAINTS_FIELDS } from '../../initializers/constants'import { PlaylistElementObject } from '../../../shared/models/activitypub/objects/playlist-element-object'import * as validator from 'validator'import { AggregateOptions, Op, ScopeOptions, Sequelize, Transaction } from 'sequelize'-import { UserModel } from '../account/user'import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../shared/models/videos/playlist/video-playlist-element.model'import { AccountModel } from '../account/account'import { VideoPrivacy } from '../../../shared/models/videos'import * as Bluebird from 'bluebird'-import { MVideoPlaylistAP, MVideoPlaylistElement, MVideoPlaylistVideoThumbnail } from '@server/typings/models/video/video-playlist-element'+import {+ MVideoPlaylistElement,+ MVideoPlaylistElementAP,+ MVideoPlaylistElementFormattable,+ MVideoPlaylistVideoThumbnail+} from '@server/typings/models/video/video-playlist-element'import { MUserAccountId } from '@server/typings/models'@Table({@@ -180,7 +184,7 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel>return VideoPlaylistElementModel.findByPk(playlistElementId)}- static loadByPlaylistAndVideoForAP (playlistId: number | string, videoId: number | string): Bluebird<MVideoPlaylistAP> {+ static loadByPlaylistAndVideoForAP (playlistId: number | string, videoId: number | string): Bluebird<MVideoPlaylistElementAP> {const playlistWhere = validator.isUUID('' + playlistId) ? { uuid: playlistId } : { id: playlistId }const videoWhere = validator.isUUID('' + videoId) ? { uuid: videoId } : { id: videoId }@@ -293,7 +297,7 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel>return VideoPlaylistElementModel.increment({ position: by }, query)}- getType (displayNSFW?: boolean, accountId?: number) {+ getType (this: MVideoPlaylistElementFormattable, displayNSFW?: boolean, accountId?: number) {const video = this.Videoif (!video) return VideoPlaylistElementType.DELETED@@ -309,14 +313,17 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel>return VideoPlaylistElementType.REGULAR}- getVideoElement (displayNSFW?: boolean, accountId?: number) {+ getVideoElement (this: MVideoPlaylistElementFormattable, displayNSFW?: boolean, accountId?: number) {if (!this.Video) return nullif (this.getType(displayNSFW, accountId) !== VideoPlaylistElementType.REGULAR) return nullreturn this.Video.toFormattedJSON()}- toFormattedJSON (options: { displayNSFW?: boolean, accountId?: number } = {}): VideoPlaylistElement {+ toFormattedJSON (+ this: MVideoPlaylistElementFormattable,+ options: { displayNSFW?: boolean, accountId?: number } = {}+ ): VideoPlaylistElement {return {id: this.id,position: this.position,diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.tsindex 9f1d03ac5e..80dd653229 100644--- a/server/models/video/video-playlist.ts+++ b/server/models/video/video-playlist.ts@@ -46,6 +46,7 @@ import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } froimport * as Bluebird from 'bluebird'import {MVideoPlaylistAccountThumbnail,+ MVideoPlaylistFormattable,MVideoPlaylistFull,MVideoPlaylistFullSummary,MVideoPlaylistIdWithElements@@ -479,7 +480,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {return isOutdated(this, ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL)}- toFormattedJSON (): VideoPlaylist {+ toFormattedJSON (this: MVideoPlaylistFormattable): VideoPlaylist {return {id: this.id,uuid: this.uuid,diff --git a/server/models/video/video.ts b/server/models/video/video.tsindex e62bde344f..9c24d1ba88 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -132,8 +132,9 @@ import {MVideoFullLight,MVideoIdThumbnail,MVideoThumbnail,- MVideoWithAllFiles,- MVideoWithRights+ MVideoWithAllFiles, MVideoWithFile,+ MVideoWithRights,+ MVideoFormattable} from '../../typings/models'import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'import { MThumbnail } from '../../typings/models/video/thumbnail'@@ -1765,14 +1766,14 @@ export class VideoModel extends Model<VideoModel> {this.VideoChannel.Account.isBlocked()}- getOriginalFile () {+ getOriginalFile <T extends MVideoWithFile> (this: T) {if (Array.isArray(this.VideoFiles) === false) return undefined// The original file is the file that have the higher resolutionreturn maxBy(this.VideoFiles, file => file.resolution)}- getFile (resolution: number) {+ getFile <T extends MVideoWithFile> (this: T, resolution: number) {if (Array.isArray(this.VideoFiles) === false) return undefinedreturn this.VideoFiles.find(f => f.resolution === resolution)@@ -1878,7 +1879,7 @@ export class VideoModel extends Model<VideoModel> {return join(LAZY_STATIC_PATHS.PREVIEWS, preview.filename)}- toFormattedJSON (options?: VideoFormattingJSONOptions): Video {+ toFormattedJSON <T extends MVideoFormattable> (this: T, options?: VideoFormattingJSONOptions): Video {return videoModelToFormattedJSON(this, options)}diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.tsindex d20d97aa8f..c9cb553325 100644--- a/server/typings/models/account/account-blocklist.ts+++ b/server/typings/models/account/account-blocklist.ts@@ -1,6 +1,6 @@import { AccountBlocklistModel } from '../../../models/account/account-blocklist'import { PickWith } from '../../utils'-import { MAccountDefault } from './account'+import { MAccountDefault, MAccountFormattable } from './account'type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M>@@ -15,3 +15,11 @@ export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'>export type MAccountBlocklistAccounts = MAccountBlocklist &Use<'ByAccount', MAccountDefault> &Use<'BlockedAccount', MAccountDefault>++// ############################################################################++// Format for API or AP object++export type MAccountBlocklistFormattable = Pick<MAccountBlocklist, 'createdAt'> &+ Use<'ByAccount', MAccountFormattable> &+ Use<'BlockedAccount', MAccountFormattable>diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.tsindex 9a8784e6bc..33940517ea 100644--- a/server/typings/models/account/account.ts+++ b/server/typings/models/account/account.ts@@ -9,9 +9,11 @@ import {MActorId,MActorServer,MActorSummary,- MActorUrl+ MActorSummaryFormattable,+ MActorUrl,+ MActorFormattable} from './actor'-import { PickWith } from '../../utils'+import { FunctionProperties, PickWith } from '../../utils'import { MAccountBlocklistId } from './account-blocklist'import { MChannelDefault } from '@server/typings/models'@@ -67,7 +69,8 @@ export type MAccountServer = MAccount &// For API-export type MAccountSummary = Pick<MAccount, 'id' | 'name'> &+export type MAccountSummary = FunctionProperties<MAccount> &+ Pick<MAccount, 'id' | 'name'> &Use<'Actor', MActorSummary>export type MAccountSummaryBlocks = MAccountSummary &@@ -75,3 +78,15 @@ export type MAccountSummaryBlocks = MAccountSummary &export type MAccountAPI = MAccount &Use<'Actor', MActorAPI>++// ############################################################################++// Format for API or AP object++export type MAccountSummaryFormattable = FunctionProperties<MAccount> &+ Pick<MAccount, 'id' | 'name'> &+ Use<'Actor', MActorSummaryFormattable>++export type MAccountFormattable = FunctionProperties<MAccount> &+ Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> &+ Use<'Actor', MActorFormattable>diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.tsindex 87050ac63f..17a47b8df7 100644--- a/server/typings/models/account/actor-follow.ts+++ b/server/typings/models/account/actor-follow.ts@@ -3,14 +3,15 @@ import {MActor,MActorAccount,MActorAccountChannel,- MActorChannel,MActorChannelAccountActor,MActorDefault,+ MActorFormattable,MActorHost,MActorUsername} from './actor'import { PickWith } from '../../utils'import { ActorModel } from '@server/models/activitypub/actor'+import { MChannelDefault } from '@server/typings/models'type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>@@ -43,9 +44,12 @@ export type MActorFollowFull = MActorFollow &// For subscriptions+type SubscriptionFollowing = MActorDefault &+ PickWith<ActorModel, 'VideoChannel', MChannelDefault>+export type MActorFollowActorsDefaultSubscription = MActorFollow &Use<'ActorFollower', MActorDefault> &- Use<'ActorFollowing', MActorDefault & MActorChannel>+ Use<'ActorFollowing', SubscriptionFollowing>export type MActorFollowFollowingFullFollowerAccount = MActorFollow &Use<'ActorFollower', MActorAccount> &@@ -53,3 +57,11 @@ export type MActorFollowFollowingFullFollowerAccount = MActorFollow &export type MActorFollowSubscriptions = MActorFollow &Use<'ActorFollowing', MActorChannelAccountActor>++// ############################################################################++// Format for API or AP object++export type MActorFollowFormattable = Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> &+ Use<'ActorFollower', MActorFormattable> &+ Use<'ActorFollowing', MActorFormattable>diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.tsindex 7d99a433b3..14ab2cd5b1 100644--- a/server/typings/models/account/actor.ts+++ b/server/typings/models/account/actor.ts@@ -1,8 +1,8 @@import { ActorModel } from '../../../models/activitypub/actor'-import { PickWith } from '../../utils'+import { FunctionProperties, PickWith } from '../../utils'import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'-import { MServer, MServerHost, MServerHostBlocks } from '../server'-import { MAvatar } from './avatar'+import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server'+import { MAvatar, MAvatarFormattable } from './avatar'import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>@@ -29,6 +29,7 @@ export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>// Some association attributesexport type MActorHost = Use<'Server', MServerHost>+export type MActorRedundancyAllowed = Use<'Server', MServerRedundancyAllowed>export type MActorDefaultLight = MActorLight &Use<'Server', MServerHost> &@@ -92,7 +93,8 @@ export type MActorFullActor = MActor &// API-export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &+export type MActorSummary = FunctionProperties<MActor> &+ Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &Use<'Server', MServerHost> &Use<'Avatar', MAvatar>@@ -101,3 +103,16 @@ export type MActorSummaryBlocks = MActorSummary &export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>++// ############################################################################++// Format for API or AP object++export type MActorSummaryFormattable = FunctionProperties<MActor> &+ Pick<MActor, 'url' | 'preferredUsername'> &+ Use<'Server', MServerHost> &+ Use<'Avatar', MAvatarFormattable>++export type MActorFormattable = MActorSummaryFormattable &+ Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> &+ Use<'Server', MServer>diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.tsindex 257c48bfc6..8af6cc7877 100644--- a/server/typings/models/account/avatar.ts+++ b/server/typings/models/account/avatar.ts@@ -1,3 +1,11 @@import { AvatarModel } from '../../../models/avatar/avatar'+import { FunctionProperties } from '@server/typings/utils'export type MAvatar = AvatarModel++// ############################################################################++// Format for API or AP object++export type MAvatarFormattable = FunctionProperties<MAvatar> &+ Pick<MAvatar, 'filename' | 'createdAt' | 'updatedAt'>diff --git a/server/typings/models/server/plugin.ts b/server/typings/models/server/plugin.tsindex b1e2e149d3..94674c318b 100644--- a/server/typings/models/server/plugin.ts+++ b/server/typings/models/server/plugin.ts@@ -1,3 +1,10 @@import { PluginModel } from '@server/models/server/plugin'export type MPlugin = PluginModel++// ############################################################################++// Format for API or AP object++export type MPluginFormattable = Pick<MPlugin, 'name' | 'type' | 'version' | 'latestVersion' | 'enabled' | 'uninstalled'+ | 'peertubeEngine' | 'description' | 'homepage' | 'settings' | 'createdAt' | 'updatedAt'>diff --git a/server/typings/models/server/server-blocklist.ts b/server/typings/models/server/server-blocklist.tsindex 0ca00b5c2d..c81f604f5b 100644--- a/server/typings/models/server/server-blocklist.ts+++ b/server/typings/models/server/server-blocklist.ts@@ -1,6 +1,6 @@import { ServerBlocklistModel } from '@server/models/server/server-blocklist'import { PickWith } from '@server/typings/utils'-import { MAccountDefault, MServer } from '@server/typings/models'+import { MAccountDefault, MAccountFormattable, MServer, MServerFormattable } from '@server/typings/models'type Use<K extends keyof ServerBlocklistModel, M> = PickWith<ServerBlocklistModel, K, M>@@ -13,3 +13,11 @@ export type MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'Blockedexport type MServerBlocklistAccountServer = MServerBlocklist &Use<'ByAccount', MAccountDefault> &Use<'BlockedServer', MServer>++// ############################################################################++// Format for API or AP object++export type MServerBlocklistFormattable = Pick<MServerBlocklist, 'createdAt'> &+ Use<'ByAccount', MAccountFormattable> &+ Use<'BlockedServer', MServerFormattable>diff --git a/server/typings/models/server/server.ts b/server/typings/models/server/server.tsindex c059cff792..190cc0c289 100644--- a/server/typings/models/server/server.ts+++ b/server/typings/models/server/server.ts@@ -1,5 +1,5 @@import { ServerModel } from '../../../models/server/server'-import { PickWith } from '../../utils'+import { FunctionProperties, PickWith } from '../../utils'import { MAccountBlocklistId } from '../account'type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M>@@ -11,6 +11,14 @@ export type MServer = Omit<ServerModel, 'Actors' | 'BlockedByAccounts'>// ############################################################################export type MServerHost = Pick<MServer, 'host'>+export type MServerRedundancyAllowed = Pick<MServer, 'redundancyAllowed'>export type MServerHostBlocks = MServerHost &Use<'BlockedByAccounts', MAccountBlocklistId[]>++// ############################################################################++// Format for API or AP object++export type MServerFormattable = FunctionProperties<MServer> &+ Pick<MServer, 'host'>diff --git a/server/typings/models/user/user-notification-setting.ts b/server/typings/models/user/user-notification-setting.tsindex 585d30a668..c674add1b7 100644--- a/server/typings/models/user/user-notification-setting.ts+++ b/server/typings/models/user/user-notification-setting.ts@@ -1,3 +1,9 @@import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting'export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'>++// ############################################################################++// Format for API or AP object++export type MNotificationSettingFormattable = MNotificationSettingdiff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.tsindex 466cde33b8..52d6d4a057 100644--- a/server/typings/models/user/user.ts+++ b/server/typings/models/user/user.ts@@ -1,7 +1,17 @@import { UserModel } from '../../../models/account/user'-import { PickWith } from '../../utils'-import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'-import { MNotificationSetting } from './user-notification-setting'+import { PickWith, PickWithOpt } from '../../utils'+import {+ MAccount,+ MAccountDefault,+ MAccountDefaultChannelDefault,+ MAccountFormattable,+ MAccountId,+ MAccountIdActorId,+ MAccountUrl+} from '../account'+import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting'+import { AccountModel } from '@server/models/account/account'+import { MChannelFormattable } from '@server/typings/models'type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>@@ -11,6 +21,7 @@ export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoIm// ############################################################################+export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }export type MUserId = Pick<UserModel, 'id'>// ############################################################################@@ -49,3 +60,11 @@ export type MUserNotifSettingAccount = MUser &export type MUserDefault = MUser &Use<'NotificationSetting', MNotificationSetting> &Use<'Account', MAccountDefault>++// ############################################################################++// Format for API or AP object++export type MUserFormattable = MUserQuotaUsed &+ Use<'Account', MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>> &+ PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>diff --git a/server/typings/models/video/schedule-video-update.ts b/server/typings/models/video/schedule-video-update.tsindex 069705536b..ada9af06e8 100644--- a/server/typings/models/video/schedule-video-update.ts+++ b/server/typings/models/video/schedule-video-update.ts@@ -1,3 +1,9 @@import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'export type MScheduleVideoUpdate = Omit<ScheduleVideoUpdateModel, 'Video'>++// ############################################################################++// Format for API or AP object++export type MScheduleVideoUpdateFormattable = Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>diff --git a/server/typings/models/video/video-abuse.ts b/server/typings/models/video/video-abuse.tsindex 0474cac5b4..e38c3f5860 100644--- a/server/typings/models/video/video-abuse.ts+++ b/server/typings/models/video/video-abuse.ts@@ -1,7 +1,7 @@import { VideoAbuseModel } from '../../../models/video/video-abuse'import { PickWith } from '../../utils'import { MVideo } from './video'-import { MAccountDefault } from '../account'+import { MAccountDefault, MAccountFormattable } from '../account'type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M>@@ -21,3 +21,11 @@ export type MVideoAbuseAccountVideo = MVideoAbuse &Pick<VideoAbuseModel, 'toActivityPubObject'> &Use<'Video', MVideo> &Use<'Account', MAccountDefault>++// ############################################################################++// Format for API or AP object++export type MVideoAbuseFormattable = MVideoAbuse &+ Use<'Account', MAccountFormattable> &+ Use<'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>diff --git a/server/typings/models/video/video-blacklist.ts b/server/typings/models/video/video-blacklist.tsindex cc539f95cf..1dedfa37f7 100644--- a/server/typings/models/video/video-blacklist.ts+++ b/server/typings/models/video/video-blacklist.ts@@ -1,6 +1,6 @@import { VideoBlacklistModel } from '../../../models/video/video-blacklist'import { PickWith } from '@server/typings/utils'-import { MVideo } from '@server/typings/models'+import { MVideo, MVideoFormattable } from '@server/typings/models'type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M>@@ -15,3 +15,10 @@ export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'>export type MVideoBlacklistVideo = MVideoBlacklist &Use<'Video', MVideo>++// ############################################################################++// Format for API or AP object++export type MVideoBlacklistFormattable = MVideoBlacklist &+ Use<'Video', MVideoFormattable>diff --git a/server/typings/models/video/video-caption.ts b/server/typings/models/video/video-caption.tsindex fe0e664c2a..7cb2a2ad32 100644--- a/server/typings/models/video/video-caption.ts+++ b/server/typings/models/video/video-caption.ts@@ -1,6 +1,6 @@import { VideoCaptionModel } from '../../../models/video/video-caption'-import { PickWith } from '@server/typings/utils'-import { VideoModel } from '@server/models/video/video'+import { FunctionProperties, PickWith } from '@server/typings/utils'+import { MVideo, MVideoUUID } from '@server/typings/models'type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M>@@ -13,4 +13,12 @@ export type MVideoCaption = Omit<VideoCaptionModel, 'Video'>export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'>export type MVideoCaptionVideo = MVideoCaption &- Use<'Video', Pick<VideoModel, 'id' | 'remote' | 'uuid'>>+ Use<'Video', Pick<MVideo, 'id' | 'remote' | 'uuid'>>++// ############################################################################++// Format for API or AP object++export type MVideoCaptionFormattable = FunctionProperties<MVideoCaption> &+ Pick<MVideoCaption, 'language'> &+ Use<'Video', MVideoUUID>diff --git a/server/typings/models/video/video-change-ownership.ts b/server/typings/models/video/video-change-ownership.tsindex 0410115c6b..72634cdb2a 100644--- a/server/typings/models/video/video-change-ownership.ts+++ b/server/typings/models/video/video-change-ownership.ts@@ -1,6 +1,6 @@import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'import { PickWith } from '@server/typings/utils'-import { MAccountDefault, MVideoWithFileThumbnail } from '@server/typings/models'+import { MAccountDefault, MAccountFormattable, MVideo, MVideoWithFileThumbnail } from '@server/typings/models'type Use<K extends keyof VideoChangeOwnershipModel, M> = PickWith<VideoChangeOwnershipModel, K, M>@@ -12,3 +12,12 @@ export type MVideoChangeOwnershipFull = MVideoChangeOwnership &Use<'Initiator', MAccountDefault> &Use<'NextOwner', MAccountDefault> &Use<'Video', MVideoWithFileThumbnail>++// ############################################################################++// Format for API or AP object++export type MVideoChangeOwnershipFormattable = Pick<MVideoChangeOwnership, 'id' | 'status' | 'createdAt'> &+ Use<'Initiator', MAccountFormattable> &+ Use<'NextOwner', MAccountFormattable> &+ Use<'Video', Pick<MVideo, 'id' | 'uuid' | 'url' | 'name'>>diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.tsindex b6506ed9f6..2be7dd7ed0 100644--- a/server/typings/models/video/video-channels.ts+++ b/server/typings/models/video/video-channels.ts@@ -1,19 +1,23 @@-import { PickWith } from '../../utils'+import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'import { VideoChannelModel } from '../../../models/video/video-channel'import {MAccountActor,MAccountAPI,MAccountDefault,+ MAccountFormattable,MAccountLight,MAccountSummaryBlocks,+ MAccountSummaryFormattable,MAccountUserId,MActor,MActorAccountChannelId,MActorAPI,MActorDefault,MActorDefaultLight,+ MActorFormattable,MActorLight,- MActorSummary+ MActorSummary,+ MActorSummaryFormattable} from '../account'import { MVideo } from './video'@@ -86,7 +90,8 @@ export type MChannelActorAccountDefaultVideos = MChannel &// For API-export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &+export type MChannelSummary = FunctionProperties<MChannel> &+ Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &Use<'Actor', MActorSummary>export type MChannelSummaryAccount = MChannelSummary &@@ -95,3 +100,19 @@ export type MChannelSummaryAccount = MChannelSummary &export type MChannelAPI = MChannel &Use<'Actor', MActorAPI> &Use<'Account', MAccountAPI>++// ############################################################################++// Format for API or AP object++export type MChannelSummaryFormattable = FunctionProperties<MChannel> &+ Pick<MChannel, 'id' | 'name'> &+ Use<'Actor', MActorSummaryFormattable>++export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable &+ Use<'Account', MAccountSummaryFormattable>++export type MChannelFormattable = FunctionProperties<MChannel> &+ Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &+ Use<'Actor', MActorFormattable> &+ PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.tsindex 187461213e..e8bccba0f0 100644--- a/server/typings/models/video/video-comment.ts+++ b/server/typings/models/video/video-comment.ts@@ -1,6 +1,6 @@import { VideoCommentModel } from '../../../models/video/video-comment'import { PickWith } from '../../utils'-import { MAccountDefault } from '../account'+import { MAccountDefault, MAccountFormattable } from '../account'import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video'type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M>@@ -8,6 +8,7 @@ type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K,// ############################################################################export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'>+export type MCommentTotalReplies = MComment & { totalReplies?: number }export type MCommentId = Pick<MComment, 'id'>// ############################################################################@@ -41,3 +42,10 @@ export type MCommentOwnerVideoFeed = MCommentOwner &// ############################################################################export type MCommentAPI = MComment & { totalReplies: number }++// ############################################################################++// Format for API or AP object++export type MCommentFormattable = MCommentTotalReplies &+ Use<'Account', MAccountFormattable>diff --git a/server/typings/models/video/video-import.ts b/server/typings/models/video/video-import.tsindex ada7237134..c6a1c5b667 100644--- a/server/typings/models/video/video-import.ts+++ b/server/typings/models/video/video-import.ts@@ -1,6 +1,6 @@import { VideoImportModel } from '@server/models/video/video-import'-import { PickWith } from '@server/typings/utils'-import { MUser, MVideo, MVideoAccountLight, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models'+import { PickWith, PickWithOpt } from '@server/typings/utils'+import { MUser, MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models'type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M>@@ -22,3 +22,10 @@ export type MVideoImportDefault = MVideoImport &export type MVideoImportDefaultFiles = MVideoImport &Use<'User', MUser> &Use<'Video', VideoAssociation & MVideoWithFile>++// ############################################################################++// Format for API or AP object++export type MVideoImportFormattable = MVideoImport &+ PickWithOpt<VideoImportModel, 'Video', MVideoFormattable & MVideoTag>diff --git a/server/typings/models/video/video-playlist-element.ts b/server/typings/models/video/video-playlist-element.tsindex 5a039d7b19..1c256fd25c 100644--- a/server/typings/models/video/video-playlist-element.ts+++ b/server/typings/models/video/video-playlist-element.ts@@ -1,6 +1,6 @@import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'import { PickWith } from '@server/typings/utils'-import { MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models'+import { MVideoFormattable, MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models'type Use<K extends keyof VideoPlaylistElementModel, M> = PickWith<VideoPlaylistElementModel, K, M>@@ -23,6 +23,13 @@ export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement &// For API-export type MVideoPlaylistAP = MVideoPlaylistElement &+export type MVideoPlaylistElementAP = MVideoPlaylistElement &Use<'Video', MVideoUrl> &Use<'VideoPlaylist', MVideoPlaylistPrivacy>++// ############################################################################++// Format for API or AP object++export type MVideoPlaylistElementFormattable = MVideoPlaylistElement &+ Use<'Video', MVideoFormattable>diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.tsindex 6338184057..a926106c5b 100644--- a/server/typings/models/video/video-playlist.ts+++ b/server/typings/models/video/video-playlist.ts@@ -1,8 +1,8 @@import { VideoPlaylistModel } from '../../../models/video/video-playlist'import { PickWith } from '../../utils'-import { MAccount, MAccountDefault, MAccountSummary } from '../account'+import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account'import { MThumbnail } from './thumbnail'-import { MChannelDefault, MChannelSummary } from './video-channels'+import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable } from './video-channels'import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element'type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M>@@ -16,7 +16,7 @@ export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChaexport type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'>export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'>export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'>-export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number }+export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength?: number }// ############################################################################@@ -78,3 +78,11 @@ export type MVideoPlaylistFullSummary = MVideoPlaylist &Use<'Thumbnail', MThumbnail> &Use<'OwnerAccount', MAccountSummary> &Use<'VideoChannel', MChannelSummary>++// ############################################################################++// Format for API or AP object++export type MVideoPlaylistFormattable = MVideoPlaylistVideosLength &+ Use<'OwnerAccount', MAccountSummaryFormattable> &+ Use<'VideoChannel', MChannelSummaryFormattable>diff --git a/server/typings/models/video/video-rate.ts b/server/typings/models/video/video-rate.tsindex fc93299935..2ff8a625b9 100644--- a/server/typings/models/video/video-rate.ts+++ b/server/typings/models/video/video-rate.ts@@ -1,6 +1,6 @@import { AccountVideoRateModel } from '@server/models/account/account-video-rate'import { PickWith } from '@server/typings/utils'-import { MAccountAudience, MAccountUrl, MVideo } from '..'+import { MAccountAudience, MAccountUrl, MVideo, MVideoFormattable } from '..'type Use<K extends keyof AccountVideoRateModel, M> = PickWith<AccountVideoRateModel, K, M>@@ -14,3 +14,10 @@ export type MAccountVideoRateAccountUrl = MAccountVideoRate &export type MAccountVideoRateAccountVideo = MAccountVideoRate &Use<'Account', MAccountAudience> &Use<'Video', MVideo>++// ############################################################################++// Format for API or AP object++export type MAccountVideoRateFormattable = Pick<MAccountVideoRate, 'type'> &+ Use<'Video', MVideoFormattable>diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.tsindex 914eb7f577..bc6d56607e 100644--- a/server/typings/models/video/video.ts+++ b/server/typings/models/video/video.ts@@ -1,12 +1,19 @@import { VideoModel } from '../../../models/video/video'import { PickWith, PickWithOpt } from '../../utils'-import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels'+import {+ MChannelAccountDefault,+ MChannelAccountLight,+ MChannelAccountSummaryFormattable,+ MChannelActor,+ MChannelFormattable,+ MChannelUserId+} from './video-channels'import { MTag } from './tag'import { MVideoCaptionLanguage } from './video-caption'import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'import { MThumbnail } from './thumbnail'-import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'+import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'import { MScheduleVideoUpdate } from './schedule-video-update'import { MUserVideoHistoryTime } from '../user/user-video-history'@@ -144,3 +151,19 @@ export type MVideoForUser = MVideo &Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &Use<'VideoBlacklist', MVideoBlacklistLight> &Use<'Thumbnails', MThumbnail[]>++// ############################################################################++// Format for API or AP object++export type MVideoFormattable = MVideo &+ PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &+ Use<'VideoChannel', MChannelAccountSummaryFormattable> &+ PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &+ PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>++export type MVideoFormattableDetails = MVideoFormattable &+ Use<'VideoChannel', MChannelFormattable> &+ Use<'Tags', MTag[]> &+ Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &+ Use<'VideoFiles', MVideoFileRedundanciesOpt[]>diff --git a/server/typings/utils.ts b/server/typings/utils.tsindex ed0fca3d15..4b5cf4d7e1 100644--- a/server/typings/utils.ts+++ b/server/typings/utils.ts@@ -4,8 +4,6 @@ export type FunctionPropertyNames<T> = {export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>-export type ValueOf <T, KT extends keyof T> = T[KT]-export type PickWith<T, KT extends keyof T, V> = {[P in KT]: T[P] extends V ? V : never}