diff options
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-caption.ts | 3 | ||||
-rw-r--r-- | server/models/video/video-channel.ts | 7 | ||||
-rw-r--r-- | server/models/video/video-comment.ts | 4 | ||||
-rw-r--r-- | server/models/video/video-format-utils.ts | 4 | ||||
-rw-r--r-- | server/models/video/video-playlist.ts | 7 | ||||
-rw-r--r-- | server/models/video/video.ts | 22 |
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' | |||
16 | import { VideoModel } from './video' | 16 | import { VideoModel } from './video' |
17 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' | 17 | import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions' |
18 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' | 18 | import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model' |
19 | import { CONFIG, STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers' | 19 | import { STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers' |
20 | import { join } from 'path' | 20 | import { join } from 'path' |
21 | import { logger } from '../../helpers/logger' | 21 | import { logger } from '../../helpers/logger' |
22 | import { remove } from 'fs-extra' | 22 | import { remove } from 'fs-extra' |
23 | import { CONFIG } from '../../initializers/config' | ||
23 | 24 | ||
24 | export enum ScopeNames { | 25 | export 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 | |||
28 | import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' | 29 | import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' |
29 | import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' | 30 | import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' |
30 | import { VideoModel } from './video' | 31 | import { VideoModel } from './video' |
31 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' | 32 | import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers' |
32 | import { ServerModel } from '../server/server' | 33 | import { ServerModel } from '../server/server' |
33 | import { DefineIndexesOptions } from 'sequelize' | 34 | import { DefineIndexesOptions } from 'sequelize' |
34 | import { AvatarModel } from '../avatar/avatar' | 35 | import { 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 | |||
18 | import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object' | 18 | import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object' |
19 | import { VideoComment } from '../../../shared/models/videos/video-comment.model' | 19 | import { VideoComment } from '../../../shared/models/videos/video-comment.model' |
20 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 20 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
21 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers' | 21 | import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers' |
22 | import { sendDeleteVideoComment } from '../../lib/activitypub/send' | 22 | import { sendDeleteVideoComment } from '../../lib/activitypub/send' |
23 | import { AccountModel } from '../account/account' | 23 | import { AccountModel } from '../account/account' |
24 | import { ActorModel } from '../activitypub/actor' | 24 | import { 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' |
10 | import { CONFIG, MIMETYPES, THUMBNAILS_SIZE } from '../../initializers' | 10 | import { MIMETYPES, THUMBNAILS_SIZE, WEBSERVER } from '../../initializers' |
11 | import { VideoCaptionModel } from './video-caption' | 11 | import { VideoCaptionModel } from './video-caption' |
12 | import { | 12 | import { |
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 { | |||
26 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 26 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
27 | import { | 27 | import { |
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' |
36 | import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model' | 36 | import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model' |
37 | import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account' | 37 | import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account' |
@@ -43,6 +43,7 @@ import { activityPubCollectionPagination } from '../../helpers/activitypub' | |||
43 | import { remove } from 'fs-extra' | 43 | import { remove } from 'fs-extra' |
44 | import { logger } from '../../helpers/logger' | 44 | import { logger } from '../../helpers/logger' |
45 | import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model' | 45 | import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model' |
46 | import { CONFIG } from '../../initializers/config' | ||
46 | 47 | ||
47 | enum ScopeNames { | 48 | enum 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' | |||
51 | import { | 51 | import { |
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' |
69 | import { sendDeleteVideo } from '../../lib/activitypub/send' | 69 | import { sendDeleteVideo } from '../../lib/activitypub/send' |
70 | import { AccountModel } from '../account/account' | 70 | import { 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' |
83 | import { TagModel } from './tag' | 84 | import { TagModel } from './tag' |
84 | import { VideoAbuseModel } from './video-abuse' | 85 | import { VideoAbuseModel } from './video-abuse' |
85 | import { VideoChannelModel, ScopeNames as VideoChannelScopeNames } from './video-channel' | 86 | import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel' |
86 | import { VideoCommentModel } from './video-comment' | 87 | import { VideoCommentModel } from './video-comment' |
87 | import { VideoFileModel } from './video-file' | 88 | import { VideoFileModel } from './video-file' |
88 | import { VideoShareModel } from './video-share' | 89 | import { VideoShareModel } from './video-share' |
@@ -105,6 +106,7 @@ import { UserModel } from '../account/user' | |||
105 | import { VideoImportModel } from './video-import' | 106 | import { VideoImportModel } from './video-import' |
106 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' | 107 | import { VideoStreamingPlaylistModel } from './video-streaming-playlist' |
107 | import { VideoPlaylistElementModel } from './video-playlist-element' | 108 | import { VideoPlaylistElementModel } from './video-playlist-element' |
109 | import { 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 |
110 | const indexes: Sequelize.DefineIndexesOptions[] = [ | 112 | const 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 |