aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/activitypub/actor-follow.ts2
-rw-r--r--server/models/application/application.ts11
-rw-r--r--server/models/redundancy/video-redundancy.ts2
-rw-r--r--server/models/video/video-comment.ts2
-rw-r--r--server/models/video/video-format-utils.ts4
-rw-r--r--server/models/video/video.ts2
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 {
20import { FollowState } from '../../../shared/models/actors' 20import { FollowState } from '../../../shared/models/actors'
21import { ActorFollow } from '../../../shared/models/actors/follow.model' 21import { ActorFollow } from '../../../shared/models/actors/follow.model'
22import { logger } from '../../helpers/logger' 22import { logger } from '../../helpers/logger'
23import { getServerActor } from '../../helpers/utils'
24import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' 23import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants'
25import { ServerModel } from '../server/server' 24import { ServerModel } from '../server/server'
26import { createSafeIn, getFollowsSort, getSort } from '../utils' 25import { createSafeIn, getFollowsSort, getSort } from '../utils'
@@ -37,6 +36,7 @@ import {
37} from '@server/typings/models' 36} from '@server/typings/models'
38import { ActivityPubActorType } from '@shared/models' 37import { ActivityPubActorType } from '@shared/models'
39import { VideoModel } from '@server/models/video/video' 38import { VideoModel } from '@server/models/video/video'
39import { 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 @@
1import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' 1import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
2import { AccountModel } from '../account/account' 2import { AccountModel } from '../account/account'
3import * as memoizee from 'memoizee'
4
5export 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 '..
17import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc' 17import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc'
18import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers/constants' 18import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers/constants'
19import { VideoFileModel } from '../video/video-file' 19import { VideoFileModel } from '../video/video-file'
20import { getServerActor } from '../../helpers/utils'
21import { VideoModel } from '../video/video' 20import { VideoModel } from '../video/video'
22import { VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../shared/models/redundancy' 21import { VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../shared/models/redundancy'
23import { logger } from '../../helpers/logger' 22import { 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'
39import { getServerActor } from '@server/models/application/application'
40 40
41export enum ScopeNames { 41export 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'
9import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils' 9import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils'
10import { VideoModel } from './video' 10import { VideoModel } from './video'
11import { VideoChannelModel } from './video-channel' 11import { VideoChannelModel } from './video-channel'
12import { getServerActor } from '../../helpers/utils'
13import { actorNameAlphabet } from '../../helpers/custom-validators/activitypub/actor' 12import { actorNameAlphabet } from '../../helpers/custom-validators/activitypub/actor'
14import { regexpCapture } from '../../helpers/regexp' 13import { regexpCapture } from '../../helpers/regexp'
15import { uniq } from 'lodash' 14import { uniq } from 'lodash'
@@ -28,6 +27,7 @@ import {
28} from '../../typings/models/video' 27} from '../../typings/models/video'
29import { MUserAccountId } from '@server/typings/models' 28import { MUserAccountId } from '@server/typings/models'
30import { VideoPrivacy } from '@shared/models' 29import { VideoPrivacy } from '@shared/models'
30import { getServerActor } from '@server/models/application/application'
31 31
32enum ScopeNames { 32enum 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'
12import { isArray } from '../../helpers/custom-validators/misc' 12import { isArray } from '../../helpers/custom-validators/misc'
13import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' 13import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model'
14import { 14import {
@@ -23,7 +23,7 @@ import {
23import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file' 23import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'
24import { VideoFile } from '@shared/models/videos/video-file.model' 24import { VideoFile } from '@shared/models/videos/video-file.model'
25import { generateMagnetUri } from '@server/helpers/webtorrent' 25import { generateMagnetUri } from '@server/helpers/webtorrent'
26import { extractVideo } from '@server/lib/videos' 26import { extractVideo } from '@server/helpers/video'
27 27
28export type VideoFormattingJSONOptions = { 28export 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'
44import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' 44import { getVideoFileResolution } from '../../helpers/ffmpeg-utils'
45import { logger } from '../../helpers/logger' 45import { logger } from '../../helpers/logger'
46import { getServerActor } from '../../helpers/utils'
47import { 46import {
48 ACTIVITY_PUB, 47 ACTIVITY_PUB,
49 API_VERSION, 48 API_VERSION,
@@ -126,6 +125,7 @@ import { getHLSDirectory, getTorrentFileName, getTorrentFilePath, getVideoFilena
126import { ModelCache } from '@server/models/model-cache' 125import { ModelCache } from '@server/models/model-cache'
127import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder' 126import { buildListQuery, BuildVideosQueryOptions, wrapForAPIResults } from './video-query-builder'
128import { buildNSFWFilter } from '@server/helpers/express-utils' 127import { buildNSFWFilter } from '@server/helpers/express-utils'
128import { getServerActor } from '@server/models/application/application'
129 129
130export enum ScopeNames { 130export enum ScopeNames {
131 AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS', 131 AVAILABLE_FOR_LIST_IDS = 'AVAILABLE_FOR_LIST_IDS',