aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
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/models
parentf92e7f76d43cbad173be87f47105b9a02032318a (diff)
downloadPeerTube-b5fecbf44192144d1ca27c23a0b53922de288c10.tar.gz
PeerTube-b5fecbf44192144d1ca27c23a0b53922de288c10.tar.zst
PeerTube-b5fecbf44192144d1ca27c23a0b53922de288c10.zip
Type toActivityPubObject functions
Diffstat (limited to 'server/models')
-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
9 files changed, 37 insertions, 25 deletions
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