diff options
-rw-r--r-- | server/lib/activitypub/actors/get.ts | 8 | ||||
-rw-r--r-- | server/lib/activitypub/actors/refresh.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/videos/get.ts | 8 | ||||
-rw-r--r-- | server/lib/activitypub/videos/refresh.ts | 4 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/activitypub-refresher.ts | 4 | ||||
-rw-r--r-- | server/lib/model-loaders/actor.ts | 9 | ||||
-rw-r--r-- | server/lib/model-loaders/video.ts | 45 | ||||
-rw-r--r-- | server/middlewares/validators/oembed.ts | 4 | ||||
-rw-r--r-- | server/middlewares/validators/shared/videos.ts | 6 |
9 files changed, 47 insertions, 45 deletions
diff --git a/server/lib/activitypub/actors/get.ts b/server/lib/activitypub/actors/get.ts index e7e87a967..c7b49d6e4 100644 --- a/server/lib/activitypub/actors/get.ts +++ b/server/lib/activitypub/actors/get.ts | |||
@@ -3,7 +3,7 @@ import { checkUrlsSameHost, getAPId } from '@server/helpers/activitypub' | |||
3 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | 3 | import { retryTransactionWrapper } from '@server/helpers/database-utils' |
4 | import { logger } from '@server/helpers/logger' | 4 | import { logger } from '@server/helpers/logger' |
5 | import { JobQueue } from '@server/lib/job-queue' | 5 | import { JobQueue } from '@server/lib/job-queue' |
6 | import { ActorFetchByUrlType, fetchActorByUrl } from '@server/lib/model-loaders' | 6 | import { ActorLoadByUrlType, loadActorByUrl } from '@server/lib/model-loaders' |
7 | import { MActor, MActorAccountChannelId, MActorAccountChannelIdActor, MActorAccountId, MActorFullActor } from '@server/types/models' | 7 | import { MActor, MActorAccountChannelId, MActorAccountChannelIdActor, MActorAccountId, MActorFullActor } from '@server/types/models' |
8 | import { ActivityPubActor } from '@shared/models' | 8 | import { ActivityPubActor } from '@shared/models' |
9 | import { refreshActorIfNeeded } from './refresh' | 9 | import { refreshActorIfNeeded } from './refresh' |
@@ -25,7 +25,7 @@ function getOrCreateAPActor ( | |||
25 | 25 | ||
26 | async function getOrCreateAPActor ( | 26 | async function getOrCreateAPActor ( |
27 | activityActor: string | ActivityPubActor, | 27 | activityActor: string | ActivityPubActor, |
28 | fetchType: ActorFetchByUrlType = 'association-ids', | 28 | fetchType: ActorLoadByUrlType = 'association-ids', |
29 | recurseIfNeeded = true, | 29 | recurseIfNeeded = true, |
30 | updateCollections = false | 30 | updateCollections = false |
31 | ): Promise<MActorFullActor | MActorAccountChannelId> { | 31 | ): Promise<MActorFullActor | MActorAccountChannelId> { |
@@ -73,8 +73,8 @@ export { | |||
73 | 73 | ||
74 | // --------------------------------------------------------------------------- | 74 | // --------------------------------------------------------------------------- |
75 | 75 | ||
76 | async function loadActorFromDB (actorUrl: string, fetchType: ActorFetchByUrlType) { | 76 | async function loadActorFromDB (actorUrl: string, fetchType: ActorLoadByUrlType) { |
77 | let actor = await fetchActorByUrl(actorUrl, fetchType) | 77 | let actor = await loadActorByUrl(actorUrl, fetchType) |
78 | 78 | ||
79 | // Orphan actor (not associated to an account of channel) so recreate it | 79 | // Orphan actor (not associated to an account of channel) so recreate it |
80 | if (actor && (!actor.Account && !actor.VideoChannel)) { | 80 | if (actor && (!actor.Account && !actor.VideoChannel)) { |
diff --git a/server/lib/activitypub/actors/refresh.ts b/server/lib/activitypub/actors/refresh.ts index 9f2289bfa..9758649a5 100644 --- a/server/lib/activitypub/actors/refresh.ts +++ b/server/lib/activitypub/actors/refresh.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { logger } from '@server/helpers/logger' | 1 | import { logger } from '@server/helpers/logger' |
2 | import { PeerTubeRequestError } from '@server/helpers/requests' | 2 | import { PeerTubeRequestError } from '@server/helpers/requests' |
3 | import { ActorFetchByUrlType } from '@server/lib/model-loaders' | 3 | import { ActorLoadByUrlType } from '@server/lib/model-loaders' |
4 | import { ActorModel } from '@server/models/actor/actor' | 4 | import { ActorModel } from '@server/models/actor/actor' |
5 | import { MActorAccountChannelId, MActorFull } from '@server/types/models' | 5 | import { MActorAccountChannelId, MActorFull } from '@server/types/models' |
6 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/core-utils' |
@@ -10,7 +10,7 @@ import { getUrlFromWebfinger } from './webfinger' | |||
10 | 10 | ||
11 | async function refreshActorIfNeeded <T extends MActorFull | MActorAccountChannelId> ( | 11 | async function refreshActorIfNeeded <T extends MActorFull | MActorAccountChannelId> ( |
12 | actorArg: T, | 12 | actorArg: T, |
13 | fetchedType: ActorFetchByUrlType | 13 | fetchedType: ActorLoadByUrlType |
14 | ): Promise<{ actor: T | MActorFull, refreshed: boolean }> { | 14 | ): Promise<{ actor: T | MActorFull, refreshed: boolean }> { |
15 | if (!actorArg.isOutdated()) return { actor: actorArg, refreshed: false } | 15 | if (!actorArg.isOutdated()) return { actor: actorArg, refreshed: false } |
16 | 16 | ||
diff --git a/server/lib/activitypub/videos/get.ts b/server/lib/activitypub/videos/get.ts index 38ba4978c..5d1f92bba 100644 --- a/server/lib/activitypub/videos/get.ts +++ b/server/lib/activitypub/videos/get.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { getAPId } from '@server/helpers/activitypub' | 1 | import { getAPId } from '@server/helpers/activitypub' |
2 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | 2 | import { retryTransactionWrapper } from '@server/helpers/database-utils' |
3 | import { JobQueue } from '@server/lib/job-queue' | 3 | import { JobQueue } from '@server/lib/job-queue' |
4 | import { fetchVideoByUrl, VideoFetchByUrlType } from '@server/lib/model-loaders' | 4 | import { loadVideoByUrl, VideoLoadByUrlType } from '@server/lib/model-loaders' |
5 | import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnail } from '@server/types/models' | 5 | import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnail } from '@server/types/models' |
6 | import { refreshVideoIfNeeded } from './refresh' | 6 | import { refreshVideoIfNeeded } from './refresh' |
7 | import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' | 7 | import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' |
@@ -47,7 +47,7 @@ async function getOrCreateAPVideo ( | |||
47 | 47 | ||
48 | // Get video url | 48 | // Get video url |
49 | const videoUrl = getAPId(options.videoObject) | 49 | const videoUrl = getAPId(options.videoObject) |
50 | let videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType) | 50 | let videoFromDatabase = await loadVideoByUrl(videoUrl, fetchType) |
51 | 51 | ||
52 | if (videoFromDatabase) { | 52 | if (videoFromDatabase) { |
53 | if (allowRefresh === true) { | 53 | if (allowRefresh === true) { |
@@ -71,7 +71,7 @@ async function getOrCreateAPVideo ( | |||
71 | } catch (err) { | 71 | } catch (err) { |
72 | // Maybe a concurrent getOrCreateAPVideo call created this video | 72 | // Maybe a concurrent getOrCreateAPVideo call created this video |
73 | if (err.name === 'SequelizeUniqueConstraintError') { | 73 | if (err.name === 'SequelizeUniqueConstraintError') { |
74 | const alreadyCreatedVideo = await fetchVideoByUrl(videoUrl, fetchType) | 74 | const alreadyCreatedVideo = await loadVideoByUrl(videoUrl, fetchType) |
75 | if (alreadyCreatedVideo) return { video: alreadyCreatedVideo, created: false } | 75 | if (alreadyCreatedVideo) return { video: alreadyCreatedVideo, created: false } |
76 | } | 76 | } |
77 | 77 | ||
@@ -87,7 +87,7 @@ export { | |||
87 | 87 | ||
88 | // --------------------------------------------------------------------------- | 88 | // --------------------------------------------------------------------------- |
89 | 89 | ||
90 | async function scheduleRefresh (video: MVideoThumbnail, fetchType: VideoFetchByUrlType, syncParam: SyncParam) { | 90 | async function scheduleRefresh (video: MVideoThumbnail, fetchType: VideoLoadByUrlType, syncParam: SyncParam) { |
91 | if (!video.isOutdated()) return video | 91 | if (!video.isOutdated()) return video |
92 | 92 | ||
93 | const refreshOptions = { | 93 | const refreshOptions = { |
diff --git a/server/lib/activitypub/videos/refresh.ts b/server/lib/activitypub/videos/refresh.ts index f1a3a6fac..82b3b13bf 100644 --- a/server/lib/activitypub/videos/refresh.ts +++ b/server/lib/activitypub/videos/refresh.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 1 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
2 | import { PeerTubeRequestError } from '@server/helpers/requests' | 2 | import { PeerTubeRequestError } from '@server/helpers/requests' |
3 | import { ActorFollowScoreCache } from '@server/lib/files-cache' | 3 | import { ActorFollowScoreCache } from '@server/lib/files-cache' |
4 | import { VideoFetchByUrlType } from '@server/lib/model-loaders' | 4 | import { VideoLoadByUrlType } from '@server/lib/model-loaders' |
5 | import { VideoModel } from '@server/models/video/video' | 5 | import { VideoModel } from '@server/models/video/video' |
6 | import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models' | 6 | import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/core-utils' |
@@ -10,7 +10,7 @@ import { APVideoUpdater } from './updater' | |||
10 | 10 | ||
11 | async function refreshVideoIfNeeded (options: { | 11 | async function refreshVideoIfNeeded (options: { |
12 | video: MVideoThumbnail | 12 | video: MVideoThumbnail |
13 | fetchedType: VideoFetchByUrlType | 13 | fetchedType: VideoLoadByUrlType |
14 | syncParam: SyncParam | 14 | syncParam: SyncParam |
15 | }): Promise<MVideoThumbnail> { | 15 | }): Promise<MVideoThumbnail> { |
16 | if (!options.video.isOutdated()) return options.video | 16 | if (!options.video.isOutdated()) return options.video |
diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/lib/job-queue/handlers/activitypub-refresher.ts index 2508a4793..f1c7d01b6 100644 --- a/server/lib/job-queue/handlers/activitypub-refresher.ts +++ b/server/lib/job-queue/handlers/activitypub-refresher.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' | 2 | import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' |
3 | import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' | 3 | import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' |
4 | import { fetchVideoByUrl } from '@server/lib/model-loaders' | 4 | import { loadVideoByUrl } from '@server/lib/model-loaders' |
5 | import { RefreshPayload } from '@shared/models' | 5 | import { RefreshPayload } from '@shared/models' |
6 | import { logger } from '../../../helpers/logger' | 6 | import { logger } from '../../../helpers/logger' |
7 | import { ActorModel } from '../../../models/actor/actor' | 7 | import { ActorModel } from '../../../models/actor/actor' |
@@ -30,7 +30,7 @@ async function refreshVideo (videoUrl: string) { | |||
30 | const fetchType = 'all' as 'all' | 30 | const fetchType = 'all' as 'all' |
31 | const syncParam = { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true } | 31 | const syncParam = { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true } |
32 | 32 | ||
33 | const videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType) | 33 | const videoFromDatabase = await loadVideoByUrl(videoUrl, fetchType) |
34 | if (videoFromDatabase) { | 34 | if (videoFromDatabase) { |
35 | const refreshOptions = { | 35 | const refreshOptions = { |
36 | video: videoFromDatabase, | 36 | video: videoFromDatabase, |
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 | } |
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts index ab117635e..e1015d7fd 100644 --- a/server/middlewares/validators/oembed.ts +++ b/server/middlewares/validators/oembed.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { fetchVideo } from '@server/lib/model-loaders' | 4 | import { loadVideo } from '@server/lib/model-loaders' |
5 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 5 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
6 | import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' | 6 | import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' |
7 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 7 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
@@ -85,7 +85,7 @@ const oembedValidator = [ | |||
85 | } | 85 | } |
86 | 86 | ||
87 | if (isVideo) { | 87 | if (isVideo) { |
88 | const video = await fetchVideo(elementId, 'all') | 88 | const video = await loadVideo(elementId, 'all') |
89 | 89 | ||
90 | if (!video) { | 90 | if (!video) { |
91 | return res.fail({ | 91 | return res.fail({ |
diff --git a/server/middlewares/validators/shared/videos.ts b/server/middlewares/validators/shared/videos.ts index a6dad4374..3134f623d 100644 --- a/server/middlewares/validators/shared/videos.ts +++ b/server/middlewares/validators/shared/videos.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import { fetchVideo, VideoFetchType } from '@server/lib/model-loaders' | 2 | import { loadVideo, VideoLoadType } from '@server/lib/model-loaders' |
3 | import { VideoChannelModel } from '@server/models/video/video-channel' | 3 | import { VideoChannelModel } from '@server/models/video/video-channel' |
4 | import { VideoFileModel } from '@server/models/video/video-file' | 4 | import { VideoFileModel } from '@server/models/video/video-file' |
5 | import { | 5 | import { |
@@ -15,10 +15,10 @@ import { | |||
15 | import { HttpStatusCode } from '@shared/core-utils' | 15 | import { HttpStatusCode } from '@shared/core-utils' |
16 | import { UserRight } from '@shared/models' | 16 | import { UserRight } from '@shared/models' |
17 | 17 | ||
18 | async function doesVideoExist (id: number | string, res: Response, fetchType: VideoFetchType = 'all') { | 18 | async function doesVideoExist (id: number | string, res: Response, fetchType: VideoLoadType = 'all') { |
19 | const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined | 19 | const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined |
20 | 20 | ||
21 | const video = await fetchVideo(id, fetchType, userId) | 21 | const video = await loadVideo(id, fetchType, userId) |
22 | 22 | ||
23 | if (video === null) { | 23 | if (video === null) { |
24 | res.fail({ | 24 | res.fail({ |