diff options
Diffstat (limited to 'server/lib/model-loaders')
-rw-r--r-- | server/lib/model-loaders/actor.ts | 9 | ||||
-rw-r--r-- | server/lib/model-loaders/video.ts | 45 |
2 files changed, 28 insertions, 26 deletions
diff --git a/server/lib/model-loaders/actor.ts b/server/lib/model-loaders/actor.ts index 234cb344f..1355d8ee2 100644 --- a/server/lib/model-loaders/actor.ts +++ b/server/lib/model-loaders/actor.ts | |||
@@ -2,15 +2,16 @@ | |||
2 | import { ActorModel } from '../../models/actor/actor' | 2 | import { ActorModel } from '../../models/actor/actor' |
3 | import { MActorAccountChannelId, MActorFull } from '../../types/models' | 3 | import { MActorAccountChannelId, MActorFull } from '../../types/models' |
4 | 4 | ||
5 | type ActorFetchByUrlType = 'all' | 'association-ids' | 5 | type ActorLoadByUrlType = 'all' | 'association-ids' |
6 | 6 | ||
7 | function fetchActorByUrl (url: string, fetchType: ActorFetchByUrlType): Promise<MActorFull | MActorAccountChannelId> { | 7 | function loadActorByUrl (url: string, fetchType: ActorLoadByUrlType): Promise<MActorFull | MActorAccountChannelId> { |
8 | if (fetchType === 'all') return ActorModel.loadByUrlAndPopulateAccountAndChannel(url) | 8 | if (fetchType === 'all') return ActorModel.loadByUrlAndPopulateAccountAndChannel(url) |
9 | 9 | ||
10 | if (fetchType === 'association-ids') return ActorModel.loadByUrl(url) | 10 | if (fetchType === 'association-ids') return ActorModel.loadByUrl(url) |
11 | } | 11 | } |
12 | 12 | ||
13 | export { | 13 | export { |
14 | ActorFetchByUrlType, | 14 | ActorLoadByUrlType, |
15 | fetchActorByUrl | 15 | |
16 | loadActorByUrl | ||
16 | } | 17 | } |
diff --git a/server/lib/model-loaders/video.ts b/server/lib/model-loaders/video.ts index 7aaf00e89..597c94395 100644 --- a/server/lib/model-loaders/video.ts +++ b/server/lib/model-loaders/video.ts | |||
@@ -8,21 +8,21 @@ import { | |||
8 | MVideoWithRights | 8 | MVideoWithRights |
9 | } from '@server/types/models' | 9 | } from '@server/types/models' |
10 | 10 | ||
11 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' | 11 | type VideoLoadType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' |
12 | 12 | ||
13 | function fetchVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight> | 13 | function loadVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight> |
14 | function fetchVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> | 14 | function loadVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> |
15 | function fetchVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail> | 15 | function loadVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail> |
16 | function fetchVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise<MVideoWithRights> | 16 | function loadVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise<MVideoWithRights> |
17 | function fetchVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoIdThumbnail> | 17 | function loadVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoIdThumbnail> |
18 | function fetchVideo ( | 18 | function loadVideo ( |
19 | id: number | string, | 19 | id: number | string, |
20 | fetchType: VideoFetchType, | 20 | fetchType: VideoLoadType, |
21 | userId?: number | 21 | userId?: number |
22 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> | 22 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> |
23 | function fetchVideo ( | 23 | function loadVideo ( |
24 | id: number | string, | 24 | id: number | string, |
25 | fetchType: VideoFetchType, | 25 | fetchType: VideoLoadType, |
26 | userId?: number | 26 | userId?: number |
27 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> { | 27 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> { |
28 | if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId) | 28 | if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId) |
@@ -36,18 +36,18 @@ function fetchVideo ( | |||
36 | if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id) | 36 | if (fetchType === 'id' || fetchType === 'none') return VideoModel.loadOnlyId(id) |
37 | } | 37 | } |
38 | 38 | ||
39 | type VideoFetchByUrlType = 'all' | 'only-video' | 'only-immutable-attributes' | 39 | type VideoLoadByUrlType = 'all' | 'only-video' | 'only-immutable-attributes' |
40 | 40 | ||
41 | function fetchVideoByUrl (url: string, fetchType: 'all'): Promise<MVideoAccountLightBlacklistAllFiles> | 41 | function loadVideoByUrl (url: string, fetchType: 'all'): Promise<MVideoAccountLightBlacklistAllFiles> |
42 | function fetchVideoByUrl (url: string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> | 42 | function loadVideoByUrl (url: string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> |
43 | function fetchVideoByUrl (url: string, fetchType: 'only-video'): Promise<MVideoThumbnail> | 43 | function loadVideoByUrl (url: string, fetchType: 'only-video'): Promise<MVideoThumbnail> |
44 | function fetchVideoByUrl ( | 44 | function loadVideoByUrl ( |
45 | url: string, | 45 | url: string, |
46 | fetchType: VideoFetchByUrlType | 46 | fetchType: VideoLoadByUrlType |
47 | ): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> | 47 | ): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> |
48 | function fetchVideoByUrl ( | 48 | function loadVideoByUrl ( |
49 | url: string, | 49 | url: string, |
50 | fetchType: VideoFetchByUrlType | 50 | fetchType: VideoLoadByUrlType |
51 | ): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> { | 51 | ): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> { |
52 | if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url) | 52 | if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url) |
53 | 53 | ||
@@ -57,8 +57,9 @@ function fetchVideoByUrl ( | |||
57 | } | 57 | } |
58 | 58 | ||
59 | export { | 59 | export { |
60 | VideoFetchType, | 60 | VideoLoadType, |
61 | VideoFetchByUrlType, | 61 | VideoLoadByUrlType, |
62 | fetchVideo, | 62 | |
63 | fetchVideoByUrl | 63 | loadVideo, |
64 | loadVideoByUrl | ||
64 | } | 65 | } |