diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/actor.ts | 6 | ||||
-rw-r--r-- | server/helpers/middlewares/accounts.ts | 7 | ||||
-rw-r--r-- | server/helpers/video.ts | 25 |
3 files changed, 18 insertions, 20 deletions
diff --git a/server/helpers/actor.ts b/server/helpers/actor.ts index 015b4a39f..a60d3ed5d 100644 --- a/server/helpers/actor.ts +++ b/server/helpers/actor.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | |||
1 | import { ActorModel } from '../models/activitypub/actor' | 2 | import { ActorModel } from '../models/activitypub/actor' |
2 | import * as Bluebird from 'bluebird' | 3 | import { MActorAccountChannelId, MActorFull } from '../types/models' |
3 | import { MActorFull, MActorAccountChannelId } from '../types/models' | ||
4 | 4 | ||
5 | type ActorFetchByUrlType = 'all' | 'association-ids' | 5 | type ActorFetchByUrlType = 'all' | 'association-ids' |
6 | 6 | ||
7 | function fetchActorByUrl (url: string, fetchType: ActorFetchByUrlType): Bluebird<MActorFull | MActorAccountChannelId> { | 7 | function fetchActorByUrl (url: string, fetchType: ActorFetchByUrlType): 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) |
diff --git a/server/helpers/middlewares/accounts.ts b/server/helpers/middlewares/accounts.ts index 23470cac6..13ae6cdf4 100644 --- a/server/helpers/middlewares/accounts.ts +++ b/server/helpers/middlewares/accounts.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import { AccountModel } from '../../models/account/account' | ||
3 | import * as Bluebird from 'bluebird' | ||
4 | import { MAccountDefault } from '../../types/models' | ||
5 | import { UserModel } from '@server/models/account/user' | 2 | import { UserModel } from '@server/models/account/user' |
6 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' |
4 | import { AccountModel } from '../../models/account/account' | ||
5 | import { MAccountDefault } from '../../types/models' | ||
7 | 6 | ||
8 | function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { | 7 | function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { |
9 | const promise = AccountModel.load(parseInt(id + '', 10)) | 8 | const promise = AccountModel.load(parseInt(id + '', 10)) |
@@ -23,7 +22,7 @@ function doesAccountNameWithHostExist (nameWithDomain: string, res: Response, se | |||
23 | return doesAccountExist(promise, res, sendNotFound) | 22 | return doesAccountExist(promise, res, sendNotFound) |
24 | } | 23 | } |
25 | 24 | ||
26 | async function doesAccountExist (p: Bluebird<MAccountDefault>, res: Response, sendNotFound: boolean) { | 25 | async function doesAccountExist (p: Promise<MAccountDefault>, res: Response, sendNotFound: boolean) { |
27 | const account = await p | 26 | const account = await p |
28 | 27 | ||
29 | if (!account) { | 28 | if (!account) { |
diff --git a/server/helpers/video.ts b/server/helpers/video.ts index 999137c6d..5d1cd7de1 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
2 | import { Response } from 'express' | 1 | import { Response } from 'express' |
3 | import { CONFIG } from '@server/initializers/config' | 2 | import { CONFIG } from '@server/initializers/config' |
4 | import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' | 3 | import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants' |
@@ -20,21 +19,21 @@ import { VideoModel } from '../models/video/video' | |||
20 | 19 | ||
21 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' | 20 | type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' |
22 | 21 | ||
23 | function fetchVideo (id: number | string, fetchType: 'all', userId?: number): Bluebird<MVideoFullLight> | 22 | function fetchVideo (id: number | string, fetchType: 'all', userId?: number): Promise<MVideoFullLight> |
24 | function fetchVideo (id: number | string, fetchType: 'only-immutable-attributes'): Bluebird<MVideoImmutable> | 23 | function fetchVideo (id: number | string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> |
25 | function fetchVideo (id: number | string, fetchType: 'only-video', userId?: number): Bluebird<MVideoThumbnail> | 24 | function fetchVideo (id: number | string, fetchType: 'only-video', userId?: number): Promise<MVideoThumbnail> |
26 | function fetchVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Bluebird<MVideoWithRights> | 25 | function fetchVideo (id: number | string, fetchType: 'only-video-with-rights', userId?: number): Promise<MVideoWithRights> |
27 | function fetchVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Bluebird<MVideoIdThumbnail> | 26 | function fetchVideo (id: number | string, fetchType: 'id' | 'none', userId?: number): Promise<MVideoIdThumbnail> |
28 | function fetchVideo ( | 27 | function fetchVideo ( |
29 | id: number | string, | 28 | id: number | string, |
30 | fetchType: VideoFetchType, | 29 | fetchType: VideoFetchType, |
31 | userId?: number | 30 | userId?: number |
32 | ): Bluebird<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> | 31 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> |
33 | function fetchVideo ( | 32 | function fetchVideo ( |
34 | id: number | string, | 33 | id: number | string, |
35 | fetchType: VideoFetchType, | 34 | fetchType: VideoFetchType, |
36 | userId?: number | 35 | userId?: number |
37 | ): Bluebird<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> { | 36 | ): Promise<MVideoFullLight | MVideoThumbnail | MVideoWithRights | MVideoIdThumbnail | MVideoImmutable> { |
38 | if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId) | 37 | if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId) |
39 | 38 | ||
40 | if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id) | 39 | if (fetchType === 'only-immutable-attributes') return VideoModel.loadImmutableAttributes(id) |
@@ -48,17 +47,17 @@ function fetchVideo ( | |||
48 | 47 | ||
49 | type VideoFetchByUrlType = 'all' | 'only-video' | 'only-immutable-attributes' | 48 | type VideoFetchByUrlType = 'all' | 'only-video' | 'only-immutable-attributes' |
50 | 49 | ||
51 | function fetchVideoByUrl (url: string, fetchType: 'all'): Bluebird<MVideoAccountLightBlacklistAllFiles> | 50 | function fetchVideoByUrl (url: string, fetchType: 'all'): Promise<MVideoAccountLightBlacklistAllFiles> |
52 | function fetchVideoByUrl (url: string, fetchType: 'only-immutable-attributes'): Bluebird<MVideoImmutable> | 51 | function fetchVideoByUrl (url: string, fetchType: 'only-immutable-attributes'): Promise<MVideoImmutable> |
53 | function fetchVideoByUrl (url: string, fetchType: 'only-video'): Bluebird<MVideoThumbnail> | 52 | function fetchVideoByUrl (url: string, fetchType: 'only-video'): Promise<MVideoThumbnail> |
54 | function fetchVideoByUrl ( | 53 | function fetchVideoByUrl ( |
55 | url: string, | 54 | url: string, |
56 | fetchType: VideoFetchByUrlType | 55 | fetchType: VideoFetchByUrlType |
57 | ): Bluebird<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> | 56 | ): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> |
58 | function fetchVideoByUrl ( | 57 | function fetchVideoByUrl ( |
59 | url: string, | 58 | url: string, |
60 | fetchType: VideoFetchByUrlType | 59 | fetchType: VideoFetchByUrlType |
61 | ): Bluebird<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> { | 60 | ): Promise<MVideoAccountLightBlacklistAllFiles | MVideoThumbnail | MVideoImmutable> { |
62 | if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url) | 61 | if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url) |
63 | 62 | ||
64 | if (fetchType === 'only-immutable-attributes') return VideoModel.loadByUrlImmutableAttributes(url) | 63 | if (fetchType === 'only-immutable-attributes') return VideoModel.loadByUrlImmutableAttributes(url) |