diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-23 09:32:53 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-05-04 16:21:39 +0200 |
commit | 8dc8a34ee8428e7657414115d1c137592efa174d (patch) | |
tree | e9b5ef0d7446d1b7766eac18da5a759edc7a9040 /server/models | |
parent | 7fed637506043e4432cbebe041ada0625171cceb (diff) | |
download | PeerTube-8dc8a34ee8428e7657414115d1c137592efa174d.tar.gz PeerTube-8dc8a34ee8428e7657414115d1c137592efa174d.tar.zst PeerTube-8dc8a34ee8428e7657414115d1c137592efa174d.zip |
Avoir some circular dependencies
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 2 | ||||
-rw-r--r-- | server/models/application/application.ts | 11 | ||||
-rw-r--r-- | server/models/redundancy/video-redundancy.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-comment.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-format-utils.ts | 4 | ||||
-rw-r--r-- | server/models/video/video.ts | 2 |
6 files changed, 17 insertions, 6 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index 5a8e450a5..85a371026 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -20,7 +20,6 @@ import { | |||
20 | import { FollowState } from '../../../shared/models/actors' | 20 | import { FollowState } from '../../../shared/models/actors' |
21 | import { ActorFollow } from '../../../shared/models/actors/follow.model' | 21 | import { ActorFollow } from '../../../shared/models/actors/follow.model' |
22 | import { logger } from '../../helpers/logger' | 22 | import { logger } from '../../helpers/logger' |
23 | import { getServerActor } from '../../helpers/utils' | ||
24 | import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' | 23 | import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' |
25 | import { ServerModel } from '../server/server' | 24 | import { ServerModel } from '../server/server' |
26 | import { createSafeIn, getFollowsSort, getSort } from '../utils' | 25 | import { createSafeIn, getFollowsSort, getSort } from '../utils' |
@@ -37,6 +36,7 @@ import { | |||
37 | } from '@server/typings/models' | 36 | } from '@server/typings/models' |
38 | import { ActivityPubActorType } from '@shared/models' | 37 | import { ActivityPubActorType } from '@shared/models' |
39 | import { VideoModel } from '@server/models/video/video' | 38 | import { VideoModel } from '@server/models/video/video' |
39 | import { getServerActor } from '@server/models/application/application' | ||
40 | 40 | ||
41 | @Table({ | 41 | @Table({ |
42 | tableName: 'actorFollow', | 42 | tableName: 'actorFollow', |
diff --git a/server/models/application/application.ts b/server/models/application/application.ts index 81320b9af..3bba2c70e 100644 --- a/server/models/application/application.ts +++ b/server/models/application/application.ts | |||
@@ -1,5 +1,16 @@ | |||
1 | import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' | 1 | import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' |
2 | import { AccountModel } from '../account/account' | 2 | import { AccountModel } from '../account/account' |
3 | import * as memoizee from 'memoizee' | ||
4 | |||
5 | export const getServerActor = memoizee(async function () { | ||
6 | const application = await ApplicationModel.load() | ||
7 | if (!application) throw Error('Could not load Application from database.') | ||
8 | |||
9 | const actor = application.Account.Actor | ||
10 | actor.Account = application.Account | ||
11 | |||
12 | return actor | ||
13 | }, { promise: true }) | ||
3 | 14 | ||
4 | @DefaultScope(() => ({ | 15 | @DefaultScope(() => ({ |
5 | include: [ | 16 | include: [ |
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 857b9eca6..6021408bf 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts | |||
@@ -17,7 +17,6 @@ import { getSort, getVideoSort, parseAggregateResult, throwIfNotValid } from '.. | |||
17 | import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 17 | import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
18 | import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers/constants' | 18 | import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers/constants' |
19 | import { VideoFileModel } from '../video/video-file' | 19 | import { VideoFileModel } from '../video/video-file' |
20 | import { getServerActor } from '../../helpers/utils' | ||
21 | import { VideoModel } from '../video/video' | 20 | import { VideoModel } from '../video/video' |
22 | import { VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../shared/models/redundancy' | 21 | import { VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../shared/models/redundancy' |
23 | import { logger } from '../../helpers/logger' | 22 | import { logger } from '../../helpers/logger' |
@@ -37,6 +36,7 @@ import { | |||
37 | StreamingPlaylistRedundancyInformation, | 36 | StreamingPlaylistRedundancyInformation, |
38 | VideoRedundancy | 37 | VideoRedundancy |
39 | } from '@shared/models/redundancy/video-redundancy.model' | 38 | } from '@shared/models/redundancy/video-redundancy.model' |
39 | import { getServerActor } from '@server/models/application/application' | ||
40 | 40 | ||
41 | export enum ScopeNames { | 41 | export enum ScopeNames { |
42 | WITH_VIDEO = 'WITH_VIDEO' | 42 | WITH_VIDEO = 'WITH_VIDEO' |
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 7cdff8c2c..b7ed6240e 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -9,7 +9,6 @@ import { ActorModel } from '../activitypub/actor' | |||
9 | import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils' | 9 | import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils' |
10 | import { VideoModel } from './video' | 10 | import { VideoModel } from './video' |
11 | import { VideoChannelModel } from './video-channel' | 11 | import { VideoChannelModel } from './video-channel' |
12 | import { getServerActor } from '../../helpers/utils' | ||
13 | import { actorNameAlphabet } from '../../helpers/custom-validators/activitypub/actor' | 12 | import { actorNameAlphabet } from '../../helpers/custom-validators/activitypub/actor' |
14 | import { regexpCapture } from '../../helpers/regexp' | 13 | import { regexpCapture } from '../../helpers/regexp' |
15 | import { uniq } from 'lodash' | 14 | import { uniq } from 'lodash' |
@@ -28,6 +27,7 @@ import { | |||
28 | } from '../../typings/models/video' | 27 | } from '../../typings/models/video' |
29 | import { MUserAccountId } from '@server/typings/models' | 28 | import { MUserAccountId } from '@server/typings/models' |
30 | import { VideoPrivacy } from '@shared/models' | 29 | import { VideoPrivacy } from '@shared/models' |
30 | import { getServerActor } from '@server/models/application/application' | ||
31 | 31 | ||
32 | enum ScopeNames { | 32 | enum ScopeNames { |
33 | WITH_ACCOUNT = 'WITH_ACCOUNT', | 33 | WITH_ACCOUNT = 'WITH_ACCOUNT', |
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts index 365c9581e..0d3c5a8ac 100644 --- a/server/models/video/video-format-utils.ts +++ b/server/models/video/video-format-utils.ts | |||
@@ -8,7 +8,7 @@ import { | |||
8 | getVideoDislikesActivityPubUrl, | 8 | getVideoDislikesActivityPubUrl, |
9 | getVideoLikesActivityPubUrl, | 9 | getVideoLikesActivityPubUrl, |
10 | getVideoSharesActivityPubUrl | 10 | getVideoSharesActivityPubUrl |
11 | } from '../../lib/activitypub' | 11 | } from '../../lib/activitypub/url' |
12 | import { isArray } from '../../helpers/custom-validators/misc' | 12 | import { isArray } from '../../helpers/custom-validators/misc' |
13 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' | 13 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' |
14 | import { | 14 | import { |
@@ -23,7 +23,7 @@ import { | |||
23 | import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' | 23 | import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' |
24 | import { VideoFile } from '@shared/models/videos/video-file.model' | 24 | import { VideoFile } from '@shared/models/videos/video-file.model' |
25 | import { generateMagnetUri } from '@server/helpers/webtorrent' | 25 | import { generateMagnetUri } from '@server/helpers/webtorrent' |
26 | import { extractVideo } from '@server/lib/videos' | 26 | import { extractVideo } from '@server/helpers/video' |
27 | 27 | ||
28 | export type VideoFormattingJSONOptions = { | 28 | export type VideoFormattingJSONOptions = { |
29 | completeDescription?: boolean | 29 | completeDescription?: boolean |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index ccb9d64ca..96b96e5ac 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -43,7 +43,6 @@ import { | |||
43 | } from '../../helpers/custom-validators/videos' | 43 | } from '../../helpers/custom-validators/videos' |
44 | import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' | 44 | import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' |
45 | import { logger } from '../../helpers/logger' | 45 | import { logger } from '../../helpers/logger' |
46 | import { getServerActor } from '../../helpers/utils' | ||
47 | import { | 46 | import { |
48 | ACTIVITY_PUB, | 47 | ACTIVITY_PUB, |
49 | API_VERSION, | 48 | API_VERSION, |
@@ -126,6 +125,7 @@ import { getHLSDirectory, getTorrentFileName, getTorrentFilePath, getVideoFilena | |||
126 | import { ModelCache } from '@server/models/model-cache' | 125 | import { ModelCache } from '@server/models/model-cache' |
127 | import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder' | 126 | import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder' |
128 | import { buildNSFWFilter } from '@server/helpers/express-utils' | 127 | import { buildNSFWFilter } from '@server/helpers/express-utils' |
128 | import { getServerActor } from '@server/models/application/application' | ||
129 | 129 | ||
130 | export enum ScopeNames { | 130 | export enum ScopeNames { |
131 | AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', | 131 | AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', |