aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/account/account.ts4
-rw-r--r--server/models/activitypub/actor.ts6
-rw-r--r--server/models/avatar/avatar.ts3
-rw-r--r--server/models/redundancy/video-redundancy.ts3
-rw-r--r--server/models/video/video-caption.ts3
-rw-r--r--server/models/video/video-channel.ts7
-rw-r--r--server/models/video/video-comment.ts4
-rw-r--r--server/models/video/video-format-utils.ts4
-rw-r--r--server/models/video/video-playlist.ts7
-rw-r--r--server/models/video/video.ts22
10 files changed, 35 insertions, 28 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index 7cc40f631..6f425024e 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -25,9 +25,9 @@ import { getSort, throwIfNotValid } from '../utils'
25import { VideoChannelModel } from '../video/video-channel' 25import { VideoChannelModel } from '../video/video-channel'
26import { VideoCommentModel } from '../video/video-comment' 26import { VideoCommentModel } from '../video/video-comment'
27import { UserModel } from './user' 27import { UserModel } from './user'
28import { CONFIG } from '../../initializers'
29import { AvatarModel } from '../avatar/avatar' 28import { AvatarModel } from '../avatar/avatar'
30import { VideoPlaylistModel } from '../video/video-playlist' 29import { VideoPlaylistModel } from '../video/video-playlist'
30import { WEBSERVER } from '../../initializers/constants'
31 31
32export enum ScopeNames { 32export enum ScopeNames {
33 SUMMARY = 'SUMMARY' 33 SUMMARY = 'SUMMARY'
@@ -199,7 +199,7 @@ export class AccountModel extends Model<AccountModel> {
199 static loadByNameWithHost (nameWithHost: string) { 199 static loadByNameWithHost (nameWithHost: string) {
200 const [ accountName, host ] = nameWithHost.split('@') 200 const [ accountName, host ] = nameWithHost.split('@')
201 201
202 if (!host || host === CONFIG.WEBSERVER.HOST) return AccountModel.loadLocalByName(accountName) 202 if (!host || host === WEBSERVER.HOST) return AccountModel.loadLocalByName(accountName)
203 203
204 return AccountModel.loadByNameAndHost(accountName, host) 204 return AccountModel.loadByNameAndHost(accountName, host)
205 } 205 }
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index 7d91e8a4a..5472c8b92 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -30,7 +30,7 @@ import {
30 isActorPublicKeyValid 30 isActorPublicKeyValid
31} from '../../helpers/custom-validators/activitypub/actor' 31} from '../../helpers/custom-validators/activitypub/actor'
32import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 32import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
33import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' 33import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers'
34import { AccountModel } from '../account/account' 34import { AccountModel } from '../account/account'
35import { AvatarModel } from '../avatar/avatar' 35import { AvatarModel } from '../avatar/avatar'
36import { ServerModel } from '../server/server' 36import { ServerModel } from '../server/server'
@@ -516,7 +516,7 @@ export class ActorModel extends Model<ActorModel> {
516 } 516 }
517 517
518 getHost () { 518 getHost () {
519 return this.Server ? this.Server.host : CONFIG.WEBSERVER.HOST 519 return this.Server ? this.Server.host : WEBSERVER.HOST
520 } 520 }
521 521
522 getRedundancyAllowed () { 522 getRedundancyAllowed () {
@@ -526,7 +526,7 @@ export class ActorModel extends Model<ActorModel> {
526 getAvatarUrl () { 526 getAvatarUrl () {
527 if (!this.avatarId) return undefined 527 if (!this.avatarId) return undefined
528 528
529 return CONFIG.WEBSERVER.URL + this.Avatar.getWebserverPath() 529 return WEBSERVER.URL + this.Avatar.getWebserverPath()
530 } 530 }
531 531
532 isOutdated () { 532 isOutdated () {
diff --git a/server/models/avatar/avatar.ts b/server/models/avatar/avatar.ts
index 303aebcc2..455835524 100644
--- a/server/models/avatar/avatar.ts
+++ b/server/models/avatar/avatar.ts
@@ -1,9 +1,10 @@
1import { join } from 'path' 1import { join } from 'path'
2import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript' 2import { AfterDestroy, AllowNull, Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript'
3import { Avatar } from '../../../shared/models/avatars/avatar.model' 3import { Avatar } from '../../../shared/models/avatars/avatar.model'
4import { CONFIG, STATIC_PATHS } from '../../initializers' 4import { STATIC_PATHS } from '../../initializers'
5import { logger } from '../../helpers/logger' 5import { logger } from '../../helpers/logger'
6import { remove } from 'fs-extra' 6import { remove } from 'fs-extra'
7import { CONFIG } from '../../initializers/config'
7 8
8@Table({ 9@Table({
9 tableName: 'avatar' 10 tableName: 'avatar'
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts
index b722bed14..39c50be5c 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -15,7 +15,7 @@ import {
15import { ActorModel } from '../activitypub/actor' 15import { ActorModel } from '../activitypub/actor'
16import { getVideoSort, throwIfNotValid } from '../utils' 16import { getVideoSort, throwIfNotValid } from '../utils'
17import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc' 17import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc'
18import { CONFIG, CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers' 18import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../initializers'
19import { VideoFileModel } from '../video/video-file' 19import { VideoFileModel } from '../video/video-file'
20import { getServerActor } from '../../helpers/utils' 20import { getServerActor } from '../../helpers/utils'
21import { VideoModel } from '../video/video' 21import { VideoModel } from '../video/video'
@@ -29,6 +29,7 @@ import { isTestInstance } from '../../helpers/core-utils'
29import * as Bluebird from 'bluebird' 29import * as Bluebird from 'bluebird'
30import * as Sequelize from 'sequelize' 30import * as Sequelize from 'sequelize'
31import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist' 31import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist'
32import { CONFIG } from '../../initializers/config'
32 33
33export enum ScopeNames { 34export enum ScopeNames {
34 WITH_VIDEO = 'WITH_VIDEO' 35 WITH_VIDEO = 'WITH_VIDEO'
diff --git a/server/models/video/video-caption.ts b/server/models/video/video-caption.ts
index b4f17b481..c670bce71 100644
--- a/server/models/video/video-caption.ts
+++ b/server/models/video/video-caption.ts
@@ -16,10 +16,11 @@ import { throwIfNotValid } from '../utils'
16import { VideoModel } from './video' 16import { VideoModel } from './video'
17import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' 17import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'
18import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' 18import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'
19import { CONFIG, STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers' 19import { STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers'
20import { join } from 'path' 20import { join } from 'path'
21import { logger } from '../../helpers/logger' 21import { logger } from '../../helpers/logger'
22import { remove } from 'fs-extra' 22import { remove } from 'fs-extra'
23import { CONFIG } from '../../initializers/config'
23 24
24export enum ScopeNames { 25export enum ScopeNames {
25 WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE' 26 WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE'
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts
index ca06048d1..1abc23eaa 100644
--- a/server/models/video/video-channel.ts
+++ b/server/models/video/video-channel.ts
@@ -8,7 +8,8 @@ import {
8 Default, 8 Default,
9 DefaultScope, 9 DefaultScope,
10 ForeignKey, 10 ForeignKey,
11 HasMany, IFindOptions, 11 HasMany,
12 IFindOptions,
12 Is, 13 Is,
13 Model, 14 Model,
14 Scopes, 15 Scopes,
@@ -28,7 +29,7 @@ import { AccountModel, ScopeNames as AccountModelScopeNames } from '../account/a
28import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' 29import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor'
29import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' 30import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils'
30import { VideoModel } from './video' 31import { VideoModel } from './video'
31import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' 32import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers'
32import { ServerModel } from '../server/server' 33import { ServerModel } from '../server/server'
33import { DefineIndexesOptions } from 'sequelize' 34import { DefineIndexesOptions } from 'sequelize'
34import { AvatarModel } from '../avatar/avatar' 35import { AvatarModel } from '../avatar/avatar'
@@ -419,7 +420,7 @@ export class VideoChannelModel extends Model<VideoChannelModel> {
419 static loadByNameWithHostAndPopulateAccount (nameWithHost: string) { 420 static loadByNameWithHostAndPopulateAccount (nameWithHost: string) {
420 const [ name, host ] = nameWithHost.split('@') 421 const [ name, host ] = nameWithHost.split('@')
421 422
422 if (!host || host === CONFIG.WEBSERVER.HOST) return VideoChannelModel.loadLocalByNameAndPopulateAccount(name) 423 if (!host || host === WEBSERVER.HOST) return VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
423 424
424 return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host) 425 return VideoChannelModel.loadByNameAndHostAndPopulateAccount(name, host)
425 } 426 }
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index 93d84c6fc..47f1cbb99 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -18,7 +18,7 @@ import { ActivityTagObject } from '../../../shared/models/activitypub/objects/co
18import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object' 18import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object'
19import { VideoComment } from '../../../shared/models/videos/video-comment.model' 19import { VideoComment } from '../../../shared/models/videos/video-comment.model'
20import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 20import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
21import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' 21import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers'
22import { sendDeleteVideoComment } from '../../lib/activitypub/send' 22import { sendDeleteVideoComment } from '../../lib/activitypub/send'
23import { AccountModel } from '../account/account' 23import { AccountModel } from '../account/account'
24import { ActorModel } from '../activitypub/actor' 24import { ActorModel } from '../activitypub/actor'
@@ -482,7 +482,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
482 let result: string[] = [] 482 let result: string[] = []
483 483
484 const localMention = `@(${actorNameAlphabet}+)` 484 const localMention = `@(${actorNameAlphabet}+)`
485 const remoteMention = `${localMention}@${CONFIG.WEBSERVER.HOST}` 485 const remoteMention = `${localMention}@${WEBSERVER.HOST}`
486 486
487 const mentionRegex = this.isOwned() 487 const mentionRegex = this.isOwned()
488 ? '(?:(?:' + remoteMention + ')|(?:' + localMention + '))' // Include local mentions? 488 ? '(?:(?:' + remoteMention + ')|(?:' + localMention + '))' // Include local mentions?
diff --git a/server/models/video/video-format-utils.ts b/server/models/video/video-format-utils.ts
index dc10fb9a2..7915fc1f9 100644
--- a/server/models/video/video-format-utils.ts
+++ b/server/models/video/video-format-utils.ts
@@ -7,7 +7,7 @@ import {
7 ActivityUrlObject, 7 ActivityUrlObject,
8 VideoTorrentObject 8 VideoTorrentObject
9} from '../../../shared/models/activitypub/objects' 9} from '../../../shared/models/activitypub/objects'
10import { CONFIG, MIMETYPES, THUMBNAILS_SIZE } from '../../initializers' 10import { MIMETYPES, THUMBNAILS_SIZE, WEBSERVER } from '../../initializers'
11import { VideoCaptionModel } from './video-caption' 11import { VideoCaptionModel } from './video-caption'
12import { 12import {
13 getVideoCommentsActivityPubUrl, 13 getVideoCommentsActivityPubUrl,
@@ -290,7 +290,7 @@ function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject {
290 type: 'Link', 290 type: 'Link',
291 mimeType: 'text/html', 291 mimeType: 'text/html',
292 mediaType: 'text/html', 292 mediaType: 'text/html',
293 href: CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid 293 href: WEBSERVER.URL + '/videos/watch/' + video.uuid
294 }) 294 })
295 295
296 const subtitleLanguage = [] 296 const subtitleLanguage = []
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index 08e4d32c8..93f36a9d0 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -26,12 +26,12 @@ import {
26import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 26import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
27import { 27import {
28 ACTIVITY_PUB, 28 ACTIVITY_PUB,
29 CONFIG,
30 CONSTRAINTS_FIELDS, 29 CONSTRAINTS_FIELDS,
31 STATIC_PATHS, 30 STATIC_PATHS,
32 THUMBNAILS_SIZE, 31 THUMBNAILS_SIZE,
33 VIDEO_PLAYLIST_PRIVACIES, 32 VIDEO_PLAYLIST_PRIVACIES,
34 VIDEO_PLAYLIST_TYPES 33 VIDEO_PLAYLIST_TYPES,
34 WEBSERVER
35} from '../../initializers' 35} from '../../initializers'
36import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model' 36import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model'
37import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account' 37import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account'
@@ -43,6 +43,7 @@ import { activityPubCollectionPagination } from '../../helpers/activitypub'
43import { remove } from 'fs-extra' 43import { remove } from 'fs-extra'
44import { logger } from '../../helpers/logger' 44import { logger } from '../../helpers/logger'
45import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model' 45import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model'
46import { CONFIG } from '../../initializers/config'
46 47
47enum ScopeNames { 48enum ScopeNames {
48 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', 49 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST',
@@ -417,7 +418,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
417 } 418 }
418 419
419 getThumbnailUrl () { 420 getThumbnailUrl () {
420 return CONFIG.WEBSERVER.URL + STATIC_PATHS.THUMBNAILS + this.getThumbnailName() 421 return WEBSERVER.URL + STATIC_PATHS.THUMBNAILS + this.getThumbnailName()
421 } 422 }
422 423
423 getThumbnailStaticPath () { 424 getThumbnailStaticPath () {
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index b0d92b674..3b30e9e28 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -51,10 +51,9 @@ import { getServerActor } from '../../helpers/utils'
51import { 51import {
52 ACTIVITY_PUB, 52 ACTIVITY_PUB,
53 API_VERSION, 53 API_VERSION,
54 CONFIG,
55 CONSTRAINTS_FIELDS, 54 CONSTRAINTS_FIELDS,
56 HLS_STREAMING_PLAYLIST_DIRECTORY,
57 HLS_REDUNDANCY_DIRECTORY, 55 HLS_REDUNDANCY_DIRECTORY,
56 HLS_STREAMING_PLAYLIST_DIRECTORY,
58 PREVIEWS_SIZE, 57 PREVIEWS_SIZE,
59 REMOTE_SCHEME, 58 REMOTE_SCHEME,
60 STATIC_DOWNLOAD_PATHS, 59 STATIC_DOWNLOAD_PATHS,
@@ -64,7 +63,8 @@ import {
64 VIDEO_LANGUAGES, 63 VIDEO_LANGUAGES,
65 VIDEO_LICENCES, 64 VIDEO_LICENCES,
66 VIDEO_PRIVACIES, 65 VIDEO_PRIVACIES,
67 VIDEO_STATES 66 VIDEO_STATES,
67 WEBSERVER
68} from '../../initializers' 68} from '../../initializers'
69import { sendDeleteVideo } from '../../lib/activitypub/send' 69import { sendDeleteVideo } from '../../lib/activitypub/send'
70import { AccountModel } from '../account/account' 70import { AccountModel } from '../account/account'
@@ -77,12 +77,13 @@ import {
77 buildTrigramSearchIndex, 77 buildTrigramSearchIndex,
78 buildWhereIdOrUUID, 78 buildWhereIdOrUUID,
79 createSimilarityAttribute, 79 createSimilarityAttribute,
80 getVideoSort, isOutdated, 80 getVideoSort,
81 isOutdated,
81 throwIfNotValid 82 throwIfNotValid
82} from '../utils' 83} from '../utils'
83import { TagModel } from './tag' 84import { TagModel } from './tag'
84import { VideoAbuseModel } from './video-abuse' 85import { VideoAbuseModel } from './video-abuse'
85import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel' 86import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel'
86import { VideoCommentModel } from './video-comment' 87import { VideoCommentModel } from './video-comment'
87import { VideoFileModel } from './video-file' 88import { VideoFileModel } from './video-file'
88import { VideoShareModel } from './video-share' 89import { VideoShareModel } from './video-share'
@@ -105,6 +106,7 @@ import { UserModel } from '../account/user'
105import { VideoImportModel } from './video-import' 106import { VideoImportModel } from './video-import'
106import { VideoStreamingPlaylistModel } from './video-streaming-playlist' 107import { VideoStreamingPlaylistModel } from './video-streaming-playlist'
107import { VideoPlaylistElementModel } from './video-playlist-element' 108import { VideoPlaylistElementModel } from './video-playlist-element'
109import { CONFIG } from '../../initializers/config'
108 110
109// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation 111// FIXME: Define indexes here because there is an issue with TS and Sequelize.literal when called directly in the annotation
110const indexes: Sequelize.DefineIndexesOptions[] = [ 112const indexes: Sequelize.DefineIndexesOptions[] = [
@@ -1664,10 +1666,10 @@ export class VideoModel extends Model<VideoModel> {
1664 name: `${this.name} ${videoFile.resolution}p${videoFile.extname}`, 1666 name: `${this.name} ${videoFile.resolution}p${videoFile.extname}`,
1665 createdBy: 'PeerTube', 1667 createdBy: 'PeerTube',
1666 announceList: [ 1668 announceList: [
1667 [ CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT + '/tracker/socket' ], 1669 [ WEBSERVER.WS + '://' + WEBSERVER.HOSTNAME + ':' + WEBSERVER.PORT + '/tracker/socket' ],
1668 [ CONFIG.WEBSERVER.URL + '/tracker/announce' ] 1670 [ WEBSERVER.URL + '/tracker/announce' ]
1669 ], 1671 ],
1670 urlList: [ CONFIG.WEBSERVER.URL + STATIC_PATHS.WEBSEED + this.getVideoFilename(videoFile) ] 1672 urlList: [ WEBSERVER.URL + STATIC_PATHS.WEBSEED + this.getVideoFilename(videoFile) ]
1671 } 1673 }
1672 1674
1673 const torrent = await createTorrentPromise(this.getVideoFilePath(videoFile), options) 1675 const torrent = await createTorrentPromise(this.getVideoFilePath(videoFile), options)
@@ -1781,8 +1783,8 @@ export class VideoModel extends Model<VideoModel> {
1781 let baseUrlWs 1783 let baseUrlWs
1782 1784
1783 if (this.isOwned()) { 1785 if (this.isOwned()) {
1784 baseUrlHttp = CONFIG.WEBSERVER.URL 1786 baseUrlHttp = WEBSERVER.URL
1785 baseUrlWs = CONFIG.WEBSERVER.WS + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT 1787 baseUrlWs = WEBSERVER.WS + '://' + WEBSERVER.HOSTNAME + ':' + WEBSERVER.PORT
1786 } else { 1788 } else {
1787 baseUrlHttp = REMOTE_SCHEME.HTTP + '://' + this.VideoChannel.Account.Actor.Server.host 1789 baseUrlHttp = REMOTE_SCHEME.HTTP + '://' + this.VideoChannel.Account.Actor.Server.host
1788 baseUrlWs = REMOTE_SCHEME.WS + '://' + this.VideoChannel.Account.Actor.Server.host 1790 baseUrlWs = REMOTE_SCHEME.WS + '://' + this.VideoChannel.Account.Actor.Server.host