aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video')
-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
6 files changed, 26 insertions, 21 deletions
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