aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-21 14:31:57 +0200
committerChocobozzz <me@florianbigard.com>2019-08-21 15:23:04 +0200
commitb5fecbf44192144d1ca27c23a0b53922de288c10 (patch)
tree03e4f1048273e6de60b8eb642fb52b2a4c68e60c /server
parentf92e7f76d43cbad173be87f47105b9a02032318a (diff)
downloadPeerTube-b5fecbf44192144d1ca27c23a0b53922de288c10.tar.gz
PeerTube-b5fecbf44192144d1ca27c23a0b53922de288c10.tar.zst
PeerTube-b5fecbf44192144d1ca27c23a0b53922de288c10.zip
Type toActivityPubObject functions
Diffstat (limited to 'server')
-rw-r--r--server/controllers/activitypub/client.ts4
-rw-r--r--server/controllers/api/video-channel.ts3
-rw-r--r--server/helpers/utils.ts5
-rw-r--r--server/lib/activitypub/send/send-update.ts6
-rw-r--r--server/middlewares/validators/videos/video-playlists.ts2
-rw-r--r--server/models/account/account.ts4
-rw-r--r--server/models/activitypub/actor.ts13
-rw-r--r--server/models/redundancy/video-redundancy.ts4
-rw-r--r--server/models/video/video-channel.ts7
-rw-r--r--server/models/video/video-comment.ts3
-rw-r--r--server/models/video/video-format-utils.ts4
-rw-r--r--server/models/video/video-playlist-element.ts8
-rw-r--r--server/models/video/video-playlist.ts4
-rw-r--r--server/models/video/video.ts15
-rw-r--r--server/typings/express.ts3
-rw-r--r--server/typings/models/account/account.ts4
-rw-r--r--server/typings/models/account/actor.ts9
-rw-r--r--server/typings/models/video/video-channels.ts10
-rw-r--r--server/typings/models/video/video-comment.ts12
-rw-r--r--server/typings/models/video/video-playlist-element.ts9
-rw-r--r--server/typings/models/video/video-playlist.ts6
-rw-r--r--server/typings/models/video/video-redundancy.ts16
-rw-r--r--server/typings/models/video/video-streaming-playlist.ts7
-rw-r--r--server/typings/models/video/video.ts4
24 files changed, 109 insertions, 53 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index 98f5c8865..453ced8bf 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -214,7 +214,7 @@ async function videoController (req: express.Request, res: express.Response) {
214 214
215 // We need captions to render AP object 215 // We need captions to render AP object
216 const captions = await VideoCaptionModel.listVideoCaptions(video.id) 216 const captions = await VideoCaptionModel.listVideoCaptions(video.id)
217 const videoWithCaptions: MVideoAPWithoutCaption = Object.assign(video, { VideoCaptions: captions }) 217 const videoWithCaptions = Object.assign(video, { VideoCaptions: captions })
218 218
219 const audience = getAudience(videoWithCaptions.VideoChannel.Account.Actor, videoWithCaptions.privacy === VideoPrivacy.PUBLIC) 219 const audience = getAudience(videoWithCaptions.VideoChannel.Account.Actor, videoWithCaptions.privacy === VideoPrivacy.PUBLIC)
220 const videoObject = audiencify(videoWithCaptions.toActivityPubObject(), audience) 220 const videoObject = audiencify(videoWithCaptions.toActivityPubObject(), audience)
@@ -351,7 +351,7 @@ async function videoPlaylistController (req: express.Request, res: express.Respo
351} 351}
352 352
353async function videoPlaylistElementController (req: express.Request, res: express.Response) { 353async function videoPlaylistElementController (req: express.Request, res: express.Response) {
354 const videoPlaylistElement = res.locals.videoPlaylistElement 354 const videoPlaylistElement = res.locals.videoPlaylistElementAP
355 355
356 const json = videoPlaylistElement.toActivityPubObject() 356 const json = videoPlaylistElement.toActivityPubObject()
357 return activityPubResponse(activityPubContextify(json), res) 357 return activityPubResponse(activityPubContextify(json), res)
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index d4ca7a0af..acc5b2987 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -35,6 +35,7 @@ import { VideoPlaylistModel } from '../../models/video/video-playlist'
35import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists' 35import { commonVideoPlaylistFiltersValidator } from '../../middlewares/validators/videos/video-playlists'
36import { CONFIG } from '../../initializers/config' 36import { CONFIG } from '../../initializers/config'
37import { sequelizeTypescript } from '../../initializers/database' 37import { sequelizeTypescript } from '../../initializers/database'
38import { MChannelAccountDefault } from '@server/typings/models'
38 39
39const auditLogger = auditLoggerFactory('channels') 40const auditLogger = auditLoggerFactory('channels')
40const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) 41const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR })
@@ -181,7 +182,7 @@ async function updateVideoChannel (req: express.Request, res: express.Response)
181 } 182 }
182 } 183 }
183 184
184 const videoChannelInstanceUpdated = await videoChannelInstance.save(sequelizeOptions) 185 const videoChannelInstanceUpdated = await videoChannelInstance.save(sequelizeOptions) as MChannelAccountDefault
185 await sendUpdateActor(videoChannelInstanceUpdated, t) 186 await sendUpdateActor(videoChannelInstanceUpdated, t)
186 187
187 auditLogger.update( 188 auditLogger.update(
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 1464b1477..ba07eaaf3 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -19,7 +19,10 @@ async function generateRandomString (size: number) {
19 return raw.toString('hex') 19 return raw.toString('hex')
20} 20}
21 21
22interface FormattableToJSON<U, V> { toFormattedJSON (args?: U): V } 22interface FormattableToJSON<U, V> {
23 toFormattedJSON (args?: U): V
24}
25
23function getFormattedObjects<U, V, T extends FormattableToJSON<U, V>> (objects: T[], objectsTotal: number, formattedArg?: U) { 26function getFormattedObjects<U, V, T extends FormattableToJSON<U, V>> (objects: T[], objectsTotal: number, formattedArg?: U) {
24 const formattedObjects = objects.map(o => o.toFormattedJSON(formattedArg)) 27 const formattedObjects = objects.map(o => o.toFormattedJSON(formattedArg))
25 28
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts
index 3a5cc1853..37517c2be 100644
--- a/server/lib/activitypub/send/send-update.ts
+++ b/server/lib/activitypub/send/send-update.ts
@@ -12,10 +12,10 @@ import { VideoCaptionModel } from '../../../models/video/video-caption'
12import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' 12import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
13import { getServerActor } from '../../../helpers/utils' 13import { getServerActor } from '../../../helpers/utils'
14import { 14import {
15 MAccountActor, 15 MAccountDefault,
16 MActor, 16 MActor,
17 MActorLight, 17 MActorLight,
18 MChannelActor, 18 MChannelDefault,
19 MVideoAP, 19 MVideoAP,
20 MVideoAPWithoutCaption, 20 MVideoAPWithoutCaption,
21 MVideoPlaylistFull, 21 MVideoPlaylistFull,
@@ -49,7 +49,7 @@ async function sendUpdateVideo (videoArg: MVideoAPWithoutCaption, t: Transaction
49 return broadcastToFollowers(updateActivity, byActor, actorsInvolved, t) 49 return broadcastToFollowers(updateActivity, byActor, actorsInvolved, t)
50} 50}
51 51
52async function sendUpdateActor (accountOrChannel: MAccountActor | MChannelActor, t: Transaction) { 52async function sendUpdateActor (accountOrChannel: MChannelDefault | MAccountDefault, t: Transaction) {
53 const byActor = accountOrChannel.Actor 53 const byActor = accountOrChannel.Actor
54 54
55 logger.info('Creating job to update actor %s.', byActor.url) 55 logger.info('Creating job to update actor %s.', byActor.url)
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index ca36d419a..27ee62b1f 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -267,7 +267,7 @@ const videoPlaylistElementAPGetValidator = [
267 return res.status(403).end() 267 return res.status(403).end()
268 } 268 }
269 269
270 res.locals.videoPlaylistElement = videoPlaylistElement 270 res.locals.videoPlaylistElementAP = videoPlaylistElement
271 271
272 return next() 272 return next()
273 } 273 }
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index 8369738b9..394a55f5e 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -32,7 +32,7 @@ import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequ
32import { AccountBlocklistModel } from './account-blocklist' 32import { AccountBlocklistModel } from './account-blocklist'
33import { ServerBlocklistModel } from '../server/server-blocklist' 33import { ServerBlocklistModel } from '../server/server-blocklist'
34import { ActorFollowModel } from '../activitypub/actor-follow' 34import { ActorFollowModel } from '../activitypub/actor-follow'
35import { MAccountActor, MAccountDefault, MAccountSummaryFormattable, MAccountFormattable } from '../../typings/models' 35import { MAccountActor, MAccountDefault, MAccountSummaryFormattable, MAccountFormattable, MAccountAP } from '../../typings/models'
36import * as Bluebird from 'bluebird' 36import * as Bluebird from 'bluebird'
37 37
38export enum ScopeNames { 38export enum ScopeNames {
@@ -380,7 +380,7 @@ export class AccountModel extends Model<AccountModel> {
380 } 380 }
381 } 381 }
382 382
383 toActivityPubObject () { 383 toActivityPubObject (this: MAccountAP) {
384 const obj = this.Actor.toActivityPubObject(this.name, 'Account') 384 const obj = this.Actor.toActivityPubObject(this.name, 'Account')
385 385
386 return Object.assign(obj, { 386 return Object.assign(obj, {
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index e2213afa1..fb4327e4f 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -39,12 +39,13 @@ import { VideoModel } from '../video/video'
39import { 39import {
40 MActor, 40 MActor,
41 MActorAccountChannelId, 41 MActorAccountChannelId,
42 MActorAP,
42 MActorFormattable, 43 MActorFormattable,
43 MActorFull, MActorHost, 44 MActorFull,
45 MActorHost,
46 MActorRedundancyAllowedOpt,
44 MActorServer, 47 MActorServer,
45 MActorSummaryFormattable, 48 MActorSummaryFormattable
46 MServerHost,
47 MActorRedundancyAllowed
48} from '../../typings/models' 49} from '../../typings/models'
49import * as Bluebird from 'bluebird' 50import * as Bluebird from 'bluebird'
50 51
@@ -429,7 +430,7 @@ export class ActorModel extends Model<ActorModel> {
429 }) 430 })
430 } 431 }
431 432
432 toActivityPubObject (name: string, type: 'Account' | 'Application' | 'VideoChannel') { 433 toActivityPubObject (this: MActorAP, name: string, type: 'Account' | 'Application' | 'VideoChannel') {
433 let activityPubType 434 let activityPubType
434 if (type === 'Account') { 435 if (type === 'Account') {
435 activityPubType = 'Person' as 'Person' 436 activityPubType = 'Person' as 'Person'
@@ -528,7 +529,7 @@ export class ActorModel extends Model<ActorModel> {
528 return this.Server ? this.Server.host : WEBSERVER.HOST 529 return this.Server ? this.Server.host : WEBSERVER.HOST
529 } 530 }
530 531
531 getRedundancyAllowed (this: MActorRedundancyAllowed) { 532 getRedundancyAllowed () {
532 return this.Server ? this.Server.redundancyAllowed : false 533 return this.Server ? this.Server.redundancyAllowed : false
533 } 534 }
534 535
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts
index 1c216b300..61d9a5612 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -30,7 +30,7 @@ import * as Bluebird from 'bluebird'
30import { col, FindOptions, fn, literal, Op, Transaction } from 'sequelize' 30import { col, FindOptions, fn, literal, Op, Transaction } from 'sequelize'
31import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist' 31import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist'
32import { CONFIG } from '../../initializers/config' 32import { CONFIG } from '../../initializers/config'
33import { MVideoRedundancy, MVideoRedundancyVideo } from '@server/typings/models' 33import { MVideoRedundancy, MVideoRedundancyAP, MVideoRedundancyVideo } from '@server/typings/models'
34 34
35export enum ScopeNames { 35export enum ScopeNames {
36 WITH_VIDEO = 'WITH_VIDEO' 36 WITH_VIDEO = 'WITH_VIDEO'
@@ -488,7 +488,7 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
488 return !!this.strategy 488 return !!this.strategy
489 } 489 }
490 490
491 toActivityPubObject (): CacheFileObject { 491 toActivityPubObject (this: MVideoRedundancyAP): CacheFileObject {
492 if (this.VideoStreamingPlaylist) { 492 if (this.VideoStreamingPlaylist) {
493 return { 493 return {
494 id: this.url, 494 id: this.url,
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index 7a4df516a..7178631b4 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -37,7 +37,10 @@ import * as Bluebird from 'bluebird'
37import { 37import {
38 MChannelAccountDefault, 38 MChannelAccountDefault,
39 MChannelActor, 39 MChannelActor,
40 MChannelActorAccountDefaultVideos, MChannelSummaryFormattable, MChannelFormattable 40 MChannelActorAccountDefaultVideos,
41 MChannelAP,
42 MChannelFormattable,
43 MChannelSummaryFormattable
41} from '../../typings/models/video' 44} from '../../typings/models/video'
42 45
43// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation 46// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation
@@ -513,7 +516,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
513 return Object.assign(actor, videoChannel) 516 return Object.assign(actor, videoChannel)
514 } 517 }
515 518
516 toActivityPubObject (): ActivityPubActor { 519 toActivityPubObject (this: MChannelAP): ActivityPubActor {
517 const obj = this.Actor.toActivityPubObject(this.name, 'VideoChannel') 520 const obj = this.Actor.toActivityPubObject(this.name, 'VideoChannel')
518 521
519 return Object.assign(obj, { 522 return Object.assign(obj, {
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index 84d71c553..2e4220434 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 'se
17import * as Bluebird from 'bluebird' 17import * as Bluebird from 'bluebird'
18import { 18import {
19 MComment, 19 MComment,
20 MCommentAP,
20 MCommentFormattable, 21 MCommentFormattable,
21 MCommentId, 22 MCommentId,
22 MCommentOwner, 23 MCommentOwner,
@@ -491,7 +492,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
491 } as VideoComment 492 } as VideoComment
492 } 493 }
493 494
494 toActivityPubObject (threadParentComments: MCommentOwner[]): VideoCommentObject { 495 toActivityPubObject (this: MCommentAP, threadParentComments: MCommentOwner[]): VideoCommentObject {
495 let inReplyTo: string 496 let inReplyTo: string
496 // New thread, so in AS we reply to the video 497 // New thread, so in AS we reply to the video
497 if (this.inReplyToCommentId === null) { 498 if (this.inReplyToCommentId === null) {
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts
index 6aa7c1e3e..2987aa780 100644
--- a/server/models/video/video-format-utils.ts
+++ b/server/models/video/video-format-utils.ts
@@ -16,7 +16,7 @@ import {
16} from '../../lib/activitypub' 16} from '../../lib/activitypub'
17import { isArray } from '../../helpers/custom-validators/misc' 17import { isArray } from '../../helpers/custom-validators/misc'
18import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' 18import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model'
19import { MVideo, MVideoAP, MVideoFormattable, MVideoFormattableDetails } from '../../typings/models' 19import { MStreamingPlaylistRedundanciesOpt, MVideo, MVideoAP, MVideoFormattable, MVideoFormattableDetails } from '../../typings/models'
20import { MStreamingPlaylistRedundancies } from '../../typings/models/video/video-streaming-playlist' 20import { MStreamingPlaylistRedundancies } from '../../typings/models/video/video-streaming-playlist'
21import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' 21import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'
22 22
@@ -143,7 +143,7 @@ function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): Vid
143 return Object.assign(formattedJson, detailsJson) 143 return Object.assign(formattedJson, detailsJson)
144} 144}
145 145
146function streamingPlaylistsModelToFormattedJSON (playlists: MStreamingPlaylistRedundancies[]): VideoStreamingPlaylist[] { 146function streamingPlaylistsModelToFormattedJSON (playlists: MStreamingPlaylistRedundanciesOpt[]): VideoStreamingPlaylist[] {
147 if (isArray(playlists) === false) return [] 147 if (isArray(playlists) === false) return []
148 148
149 return playlists 149 return playlists
diff --git a/server/models/video/video-playlist-element.ts b/server/models/video/video-playlist-element.ts
index 80ca22a18..a28021313 100644
--- a/server/models/video/video-playlist-element.ts
+++ b/server/models/video/video-playlist-element.ts
@@ -29,6 +29,7 @@ import {
29 MVideoPlaylistElement, 29 MVideoPlaylistElement,
30 MVideoPlaylistElementAP, 30 MVideoPlaylistElementAP,
31 MVideoPlaylistElementFormattable, 31 MVideoPlaylistElementFormattable,
32 MVideoPlaylistElementVideoUrlPlaylistPrivacy,
32 MVideoPlaylistVideoThumbnail 33 MVideoPlaylistVideoThumbnail
33} from '@server/typings/models/video/video-playlist-element' 34} from '@server/typings/models/video/video-playlist-element'
34import { MUserAccountId } from '@server/typings/models' 35import { MUserAccountId } from '@server/typings/models'
@@ -184,7 +185,10 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel>
184 return VideoPlaylistElementModel.findByPk(playlistElementId) 185 return VideoPlaylistElementModel.findByPk(playlistElementId)
185 } 186 }
186 187
187 static loadByPlaylistAndVideoForAP (playlistId: number | string, videoId: number | string): Bluebird<MVideoPlaylistElementAP> { 188 static loadByPlaylistAndVideoForAP (
189 playlistId: number | string,
190 videoId: number | string
191 ): Bluebird<MVideoPlaylistElementVideoUrlPlaylistPrivacy> {
188 const playlistWhere = validator.isUUID('' + playlistId) ? { uuid: playlistId } : { id: playlistId } 192 const playlistWhere = validator.isUUID('' + playlistId) ? { uuid: playlistId } : { id: playlistId }
189 const videoWhere = validator.isUUID('' + videoId) ? { uuid: videoId } : { id: videoId } 193 const videoWhere = validator.isUUID('' + videoId) ? { uuid: videoId } : { id: videoId }
190 194
@@ -336,7 +340,7 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel>
336 } 340 }
337 } 341 }
338 342
339 toActivityPubObject (): PlaylistElementObject { 343 toActivityPubObject (this: MVideoPlaylistElementAP): PlaylistElementObject {
340 const base: PlaylistElementObject = { 344 const base: PlaylistElementObject = {
341 id: this.url, 345 id: this.url,
342 type: 'PlaylistElement', 346 type: 'PlaylistElement',
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index 80dd65322..278d80ac0 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -45,7 +45,7 @@ import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
45import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' 45import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize'
46import * as Bluebird from 'bluebird' 46import * as Bluebird from 'bluebird'
47import { 47import {
48 MVideoPlaylistAccountThumbnail, 48 MVideoPlaylistAccountThumbnail, MVideoPlaylistAP,
49 MVideoPlaylistFormattable, 49 MVideoPlaylistFormattable,
50 MVideoPlaylistFull, 50 MVideoPlaylistFull,
51 MVideoPlaylistFullSummary, 51 MVideoPlaylistFullSummary,
@@ -510,7 +510,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
510 } 510 }
511 } 511 }
512 512
513 toActivityPubObject (page: number, t: Transaction): Promise<PlaylistObject> { 513 toActivityPubObject (this: MVideoPlaylistAP, page: number, t: Transaction): Promise<PlaylistObject> {
514 const handler = (start: number, count: number) => { 514 const handler = (start: number, count: number) => {
515 return VideoPlaylistElementModel.listUrlsOfForAP(this.id, start, count, t) 515 return VideoPlaylistElementModel.listUrlsOfForAP(this.id, start, count, t)
516 } 516 }
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 9c24d1ba8..ab7b49f1e 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -127,14 +127,17 @@ import {
127 MUserId, 127 MUserId,
128 MVideoAccountLight, 128 MVideoAccountLight,
129 MVideoAccountLightBlacklistAllFiles, 129 MVideoAccountLightBlacklistAllFiles,
130 MVideoAP,
130 MVideoDetails, 131 MVideoDetails,
132 MVideoFormattable,
133 MVideoFormattableDetails,
131 MVideoForUser, 134 MVideoForUser,
132 MVideoFullLight, 135 MVideoFullLight,
133 MVideoIdThumbnail, 136 MVideoIdThumbnail,
134 MVideoThumbnail, 137 MVideoThumbnail,
135 MVideoWithAllFiles, MVideoWithFile, 138 MVideoWithAllFiles,
136 MVideoWithRights, 139 MVideoWithFile,
137 MVideoFormattable 140 MVideoWithRights
138} from '../../typings/models' 141} from '../../typings/models'
139import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' 142import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'
140import { MThumbnail } from '../../typings/models/video/thumbnail' 143import { MThumbnail } from '../../typings/models/video/thumbnail'
@@ -1879,11 +1882,11 @@ export class VideoModel extends Model<VideoModel> {
1879 return join(LAZY_STATIC_PATHS.PREVIEWS, preview.filename) 1882 return join(LAZY_STATIC_PATHS.PREVIEWS, preview.filename)
1880 } 1883 }
1881 1884
1882 toFormattedJSON <T extends MVideoFormattable> (this: T, options?: VideoFormattingJSONOptions): Video { 1885 toFormattedJSON (this: MVideoFormattable, options?: VideoFormattingJSONOptions): Video {
1883 return videoModelToFormattedJSON(this, options) 1886 return videoModelToFormattedJSON(this, options)
1884 } 1887 }
1885 1888
1886 toFormattedDetailsJSON (): VideoDetails { 1889 toFormattedDetailsJSON (this: MVideoFormattableDetails): VideoDetails {
1887 return videoModelToFormattedDetailsJSON(this) 1890 return videoModelToFormattedDetailsJSON(this)
1888 } 1891 }
1889 1892
@@ -1891,7 +1894,7 @@ export class VideoModel extends Model<VideoModel> {
1891 return videoFilesModelToFormattedJSON(this, this.VideoFiles) 1894 return videoFilesModelToFormattedJSON(this, this.VideoFiles)
1892 } 1895 }
1893 1896
1894 toActivityPubObject (): VideoTorrentObject { 1897 toActivityPubObject (this: MVideoAP): VideoTorrentObject {
1895 return videoModelToActivityPubObject(this) 1898 return videoModelToActivityPubObject(this)
1896 } 1899 }
1897 1900
diff --git a/server/typings/express.ts b/server/typings/express.ts
index 1fd809c1b..3cc7c7632 100644
--- a/server/typings/express.ts
+++ b/server/typings/express.ts
@@ -22,7 +22,7 @@ import {
22import { MVideoPlaylistFull, MVideoPlaylistFullSummary } from './models/video/video-playlist' 22import { MVideoPlaylistFull, MVideoPlaylistFullSummary } from './models/video/video-playlist'
23import { MVideoImportDefault } from '@server/typings/models/video/video-import' 23import { MVideoImportDefault } from '@server/typings/models/video/video-import'
24import { MAccountBlocklist, MStreamingPlaylist, MVideoFile } from '@server/typings/models' 24import { MAccountBlocklist, MStreamingPlaylist, MVideoFile } from '@server/typings/models'
25import { MVideoPlaylistElement } from '@server/typings/models/video/video-playlist-element' 25import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/typings/models/video/video-playlist-element'
26import { MAccountVideoRateAccountVideo } from '@server/typings/models/video/video-rate' 26import { MAccountVideoRateAccountVideo } from '@server/typings/models/video/video-rate'
27import { MVideoChangeOwnershipFull } from './models/video/video-change-ownership' 27import { MVideoChangeOwnershipFull } from './models/video/video-change-ownership'
28import { MPlugin, MServer } from '@server/typings/models/server' 28import { MPlugin, MServer } from '@server/typings/models/server'
@@ -59,6 +59,7 @@ declare module 'express' {
59 videoPlaylistSummary?: MVideoPlaylistFullSummary 59 videoPlaylistSummary?: MVideoPlaylistFullSummary
60 60
61 videoPlaylistElement?: MVideoPlaylistElement 61 videoPlaylistElement?: MVideoPlaylistElement
62 videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy
62 63
63 accountVideoRate?: MAccountVideoRateAccountVideo 64 accountVideoRate?: MAccountVideoRateAccountVideo
64 65
diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts
index cd20fe81b..ec78fece8 100644
--- a/server/typings/models/account/account.ts
+++ b/server/typings/models/account/account.ts
@@ -1,6 +1,7 @@
1import { AccountModel } from '../../../models/account/account' 1import { AccountModel } from '../../../models/account/account'
2import { 2import {
3 MActor, 3 MActor,
4 MActorAP,
4 MActorAPI, 5 MActorAPI,
5 MActorAudience, 6 MActorAudience,
6 MActorDefault, 7 MActorDefault,
@@ -89,3 +90,6 @@ export type MAccountSummaryFormattable = FunctionProperties<MAccount> &
89export type MAccountFormattable = FunctionProperties<MAccount> & 90export type MAccountFormattable = FunctionProperties<MAccount> &
90 Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> & 91 Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> &
91 Use<'Actor', MActorFormattable> 92 Use<'Actor', MActorFormattable>
93
94export type MAccountAP = Pick<MAccount, 'name' | 'description'> &
95 Use<'Actor', MActorAP>
diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts
index 14ab2cd5b..d4bcac4a3 100644
--- a/server/typings/models/account/actor.ts
+++ b/server/typings/models/account/actor.ts
@@ -1,5 +1,5 @@
1import { ActorModel } from '../../../models/activitypub/actor' 1import { ActorModel } from '../../../models/activitypub/actor'
2import { FunctionProperties, PickWith } from '../../utils' 2import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
3import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' 3import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
4import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' 4import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server'
5import { MAvatar, MAvatarFormattable } from './avatar' 5import { MAvatar, MAvatarFormattable } from './avatar'
@@ -29,7 +29,7 @@ export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
29// Some association attributes 29// Some association attributes
30 30
31export type MActorHost = Use<'Server', MServerHost> 31export type MActorHost = Use<'Server', MServerHost>
32export type MActorRedundancyAllowed = Use<'Server', MServerRedundancyAllowed> 32export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed>
33 33
34export type MActorDefaultLight = MActorLight & 34export type MActorDefaultLight = MActorLight &
35 Use<'Server', MServerHost> & 35 Use<'Server', MServerHost> &
@@ -115,4 +115,7 @@ export type MActorSummaryFormattable = FunctionProperties<MActor> &
115 115
116export type MActorFormattable = MActorSummaryFormattable & 116export type MActorFormattable = MActorSummaryFormattable &
117 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> & 117 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> &
118 Use<'Server', MServer> 118 Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>>
119
120export type MActorAP = MActor &
121 Use<'Avatar', MAvatar>
diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts
index 2be7dd7ed..292d0ac95 100644
--- a/server/typings/models/video/video-channels.ts
+++ b/server/typings/models/video/video-channels.ts
@@ -8,16 +8,18 @@ import {
8 MAccountLight, 8 MAccountLight,
9 MAccountSummaryBlocks, 9 MAccountSummaryBlocks,
10 MAccountSummaryFormattable, 10 MAccountSummaryFormattable,
11 MAccountUrl,
11 MAccountUserId, 12 MAccountUserId,
12 MActor, 13 MActor,
13 MActorAccountChannelId, 14 MActorAccountChannelId,
15 MActorAP,
14 MActorAPI, 16 MActorAPI,
15 MActorDefault, 17 MActorDefault,
16 MActorDefaultLight, 18 MActorDefaultLight,
17 MActorFormattable, 19 MActorFormattable,
18 MActorLight, 20 MActorLight,
19 MActorSummary, 21 MActorSummary,
20 MActorSummaryFormattable 22 MActorSummaryFormattable, MActorUrl
21} from '../account' 23} from '../account'
22import { MVideo } from './video' 24import { MVideo } from './video'
23 25
@@ -42,6 +44,8 @@ export type MChannelUserId = Pick<MChannel, 'accountId'> &
42export type MChannelActor = MChannel & 44export type MChannelActor = MChannel &
43 Use<'Actor', MActor> 45 Use<'Actor', MActor>
44 46
47export type MChannelUrl = Use<'Actor', MActorUrl>
48
45// Default scope 49// Default scope
46export type MChannelDefault = MChannel & 50export type MChannelDefault = MChannel &
47 Use<'Actor', MActorDefault> 51 Use<'Actor', MActorDefault>
@@ -116,3 +120,7 @@ export type MChannelFormattable = FunctionProperties<MChannel> &
116 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> & 120 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
117 Use<'Actor', MActorFormattable> & 121 Use<'Actor', MActorFormattable> &
118 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable> 122 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
123
124export type MChannelAP = Pick<MChannel, 'name' | 'description' | 'support'> &
125 Use<'Actor', MActorAP> &
126 Use<'Account', MAccountUrl>
diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.ts
index e8bccba0f..4fd1c29e8 100644
--- a/server/typings/models/video/video-comment.ts
+++ b/server/typings/models/video/video-comment.ts
@@ -1,7 +1,7 @@
1import { VideoCommentModel } from '../../../models/video/video-comment' 1import { VideoCommentModel } from '../../../models/video/video-comment'
2import { PickWith } from '../../utils' 2import { PickWith, PickWithOpt } from '../../utils'
3import { MAccountDefault, MAccountFormattable } from '../account' 3import { MAccountDefault, MAccountFormattable, MAccountUrl, MActorUrl } from '../account'
4import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video' 4import { MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video'
5 5
6type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M> 6type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M>
7 7
@@ -10,6 +10,7 @@ type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K,
10export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'> 10export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'>
11export type MCommentTotalReplies = MComment & { totalReplies?: number } 11export type MCommentTotalReplies = MComment & { totalReplies?: number }
12export type MCommentId = Pick<MComment, 'id'> 12export type MCommentId = Pick<MComment, 'id'>
13export type MCommentUrl = Pick<MComment, 'url'>
13 14
14// ############################################################################ 15// ############################################################################
15 16
@@ -49,3 +50,8 @@ export type MCommentAPI = MComment & { totalReplies: number }
49 50
50export type MCommentFormattable = MCommentTotalReplies & 51export type MCommentFormattable = MCommentTotalReplies &
51 Use<'Account', MAccountFormattable> 52 Use<'Account', MAccountFormattable>
53
54export type MCommentAP = MComment &
55 Use<'Account', MAccountUrl> &
56 PickWithOpt<VideoCommentModel, 'Video', MVideoUrl> &
57 PickWithOpt<VideoCommentModel, 'InReplyToVideoComment', MCommentUrl>
diff --git a/server/typings/models/video/video-playlist-element.ts b/server/typings/models/video/video-playlist-element.ts
index 1c256fd25..7b1b993ce 100644
--- a/server/typings/models/video/video-playlist-element.ts
+++ b/server/typings/models/video/video-playlist-element.ts
@@ -19,11 +19,7 @@ export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'vid
19export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement & 19export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement &
20 Use<'Video', MVideoThumbnail> 20 Use<'Video', MVideoThumbnail>
21 21
22// ############################################################################ 22export type MVideoPlaylistElementVideoUrlPlaylistPrivacy = MVideoPlaylistElement &
23
24// For API
25
26export type MVideoPlaylistElementAP = MVideoPlaylistElement &
27 Use<'Video', MVideoUrl> & 23 Use<'Video', MVideoUrl> &
28 Use<'VideoPlaylist', MVideoPlaylistPrivacy> 24 Use<'VideoPlaylist', MVideoPlaylistPrivacy>
29 25
@@ -33,3 +29,6 @@ export type MVideoPlaylistElementAP = MVideoPlaylistElement &
33 29
34export type MVideoPlaylistElementFormattable = MVideoPlaylistElement & 30export type MVideoPlaylistElementFormattable = MVideoPlaylistElement &
35 Use<'Video', MVideoFormattable> 31 Use<'Video', MVideoFormattable>
32
33export type MVideoPlaylistElementAP = MVideoPlaylistElement &
34 Use<'Video', MVideoUrl>
diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts
index a926106c5..a40c7aca9 100644
--- a/server/typings/models/video/video-playlist.ts
+++ b/server/typings/models/video/video-playlist.ts
@@ -2,7 +2,7 @@ import { VideoPlaylistModel } from '../../../models/video/video-playlist'
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account' 3import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account'
4import { MThumbnail } from './thumbnail' 4import { MThumbnail } from './thumbnail'
5import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable } from './video-channels' 5import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels'
6import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' 6import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element'
7 7
8type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M> 8type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M>
@@ -86,3 +86,7 @@ export type MVideoPlaylistFullSummary = MVideoPlaylist &
86export type MVideoPlaylistFormattable = MVideoPlaylistVideosLength & 86export type MVideoPlaylistFormattable = MVideoPlaylistVideosLength &
87 Use<'OwnerAccount', MAccountSummaryFormattable> & 87 Use<'OwnerAccount', MAccountSummaryFormattable> &
88 Use<'VideoChannel', MChannelSummaryFormattable> 88 Use<'VideoChannel', MChannelSummaryFormattable>
89
90export type MVideoPlaylistAP = MVideoPlaylist &
91 Use<'Thumbnail', MThumbnail> &
92 Use<'VideoChannel', MChannelUrl>
diff --git a/server/typings/models/video/video-redundancy.ts b/server/typings/models/video/video-redundancy.ts
index c25eb9c09..f3846afd7 100644
--- a/server/typings/models/video/video-redundancy.ts
+++ b/server/typings/models/video/video-redundancy.ts
@@ -1,6 +1,10 @@
1import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' 1import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy'
2import { PickWith } from '@server/typings/utils' 2import { PickWith, PickWithOpt } from '@server/typings/utils'
3import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo } from '@server/typings/models' 3import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo, MVideoUrl } from '@server/typings/models'
4import { VideoStreamingPlaylist } from '../../../../shared/models/videos/video-streaming-playlist.model'
5import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
6import { VideoFile } from '../../../../shared/models/videos'
7import { VideoFileModel } from '@server/models/video/video-file'
4 8
5type Use<K extends keyof VideoRedundancyModel, M> = PickWith<VideoRedundancyModel, K, M> 9type Use<K extends keyof VideoRedundancyModel, M> = PickWith<VideoRedundancyModel, K, M>
6 10
@@ -24,3 +28,11 @@ export type MVideoRedundancyStreamingPlaylistVideo = MVideoRedundancy &
24export type MVideoRedundancyVideo = MVideoRedundancy & 28export type MVideoRedundancyVideo = MVideoRedundancy &
25 Use<'VideoFile', MVideoFileVideo> & 29 Use<'VideoFile', MVideoFileVideo> &
26 Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo> 30 Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
31
32// ############################################################################
33
34// Format for API or AP object
35
36export type MVideoRedundancyAP = MVideoRedundancy &
37 PickWithOpt<VideoRedundancyModel, 'VideoFile', MVideoFile & PickWith<VideoFileModel, 'Video', MVideoUrl>> &
38 PickWithOpt<VideoRedundancyModel, 'VideoStreamingPlaylist', PickWith<VideoStreamingPlaylistModel, 'Video', MVideoUrl>>
diff --git a/server/typings/models/video/video-streaming-playlist.ts b/server/typings/models/video/video-streaming-playlist.ts
index f1b3438b6..79696bcff 100644
--- a/server/typings/models/video/video-streaming-playlist.ts
+++ b/server/typings/models/video/video-streaming-playlist.ts
@@ -1,7 +1,7 @@
1import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist' 1import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist'
2import { PickWith } from '../../utils' 2import { PickWith, PickWithOpt } from '../../utils'
3import { MVideoRedundancyFileUrl } from './video-redundancy' 3import { MVideoRedundancyFileUrl } from './video-redundancy'
4import { MVideo } from '@server/typings/models' 4import { MVideo, MVideoUrl } from '@server/typings/models'
5 5
6type Use<K extends keyof VideoStreamingPlaylistModel, M> = PickWith<VideoStreamingPlaylistModel, K, M> 6type Use<K extends keyof VideoStreamingPlaylistModel, M> = PickWith<VideoStreamingPlaylistModel, K, M>
7 7
@@ -14,3 +14,6 @@ export type MStreamingPlaylistVideo = MStreamingPlaylist &
14 14
15export type MStreamingPlaylistRedundancies = MStreamingPlaylist & 15export type MStreamingPlaylistRedundancies = MStreamingPlaylist &
16 Use<'RedundancyVideos', MVideoRedundancyFileUrl[]> 16 Use<'RedundancyVideos', MVideoRedundancyFileUrl[]>
17
18export type MStreamingPlaylistRedundanciesOpt = MStreamingPlaylist &
19 PickWithOpt<VideoStreamingPlaylistModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.ts
index bc6d56607..be32d4617 100644
--- a/server/typings/models/video/video.ts
+++ b/server/typings/models/video/video.ts
@@ -10,7 +10,7 @@ import {
10} from './video-channels' 10} from './video-channels'
11import { MTag } from './tag' 11import { MTag } from './tag'
12import { MVideoCaptionLanguage } from './video-caption' 12import { MVideoCaptionLanguage } from './video-caption'
13import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' 13import { MStreamingPlaylist, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesOpt } from './video-streaming-playlist'
14import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' 14import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
15import { MThumbnail } from './thumbnail' 15import { MThumbnail } from './thumbnail'
16import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' 16import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
@@ -165,5 +165,5 @@ export type MVideoFormattable = MVideo &
165export type MVideoFormattableDetails = MVideoFormattable & 165export type MVideoFormattableDetails = MVideoFormattable &
166 Use<'VideoChannel', MChannelFormattable> & 166 Use<'VideoChannel', MChannelFormattable> &
167 Use<'Tags', MTag[]> & 167 Use<'Tags', MTag[]> &
168 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & 168 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
169 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> 169 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>