diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-21 14:31:57 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-21 15:23:04 +0200 |
commit | b5fecbf44192144d1ca27c23a0b53922de288c10 (patch) | |
tree | 03e4f1048273e6de60b8eb642fb52b2a4c68e60c /server/models/video | |
parent | f92e7f76d43cbad173be87f47105b9a02032318a (diff) | |
download | PeerTube-b5fecbf44192144d1ca27c23a0b53922de288c10.tar.gz PeerTube-b5fecbf44192144d1ca27c23a0b53922de288c10.tar.zst PeerTube-b5fecbf44192144d1ca27c23a0b53922de288c10.zip |
Type toActivityPubObject functions
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-channel.ts | 7 | ||||
-rw-r--r-- | server/models/video/video-comment.ts | 3 | ||||
-rw-r--r-- | server/models/video/video-format-utils.ts | 4 | ||||
-rw-r--r-- | server/models/video/video-playlist-element.ts | 8 | ||||
-rw-r--r-- | server/models/video/video-playlist.ts | 4 | ||||
-rw-r--r-- | server/models/video/video.ts | 15 |
6 files changed, 26 insertions, 15 deletions
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' | |||
37 | import { | 37 | import { |
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 | |||
17 | import * as Bluebird from 'bluebird' | 17 | import * as Bluebird from 'bluebird' |
18 | import { | 18 | import { |
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' |
17 | import { isArray } from '../../helpers/custom-validators/misc' | 17 | import { isArray } from '../../helpers/custom-validators/misc' |
18 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' | 18 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' |
19 | import { MVideo, MVideoAP, MVideoFormattable, MVideoFormattableDetails } from '../../typings/models' | 19 | import { MStreamingPlaylistRedundanciesOpt, MVideo, MVideoAP, MVideoFormattable, MVideoFormattableDetails } from '../../typings/models' |
20 | import { MStreamingPlaylistRedundancies } from '../../typings/models/video/video-streaming-playlist' | 20 | import { MStreamingPlaylistRedundancies } from '../../typings/models/video/video-streaming-playlist' |
21 | import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' | 21 | import { 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 | ||
146 | function streamingPlaylistsModelToFormattedJSON (playlists: MStreamingPlaylistRedundancies[]): VideoStreamingPlaylist[] { | 146 | function 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' |
34 | import { MUserAccountId } from '@server/typings/models' | 35 | import { 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' | |||
45 | import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' | 45 | import { FindOptions, literal, Op, ScopeOptions, Transaction, WhereOptions } from 'sequelize' |
46 | import * as Bluebird from 'bluebird' | 46 | import * as Bluebird from 'bluebird' |
47 | import { | 47 | import { |
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' |
139 | import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' | 142 | import { MVideoFile, MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' |
140 | import { MThumbnail } from '../../typings/models/video/thumbnail' | 143 | import { 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 | ||