diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/actor.ts | 5 | ||||
-rw-r--r-- | server/lib/activitypub/playlist.ts | 3 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-follow.ts | 3 | ||||
-rw-r--r-- | server/lib/activitypub/url.ts | 20 | ||||
-rw-r--r-- | server/lib/activitypub/videos.ts | 2 | ||||
-rw-r--r-- | server/lib/avatar.ts | 3 | ||||
-rw-r--r-- | server/lib/client-html.ts | 13 | ||||
-rw-r--r-- | server/lib/emailer.ts | 43 | ||||
-rw-r--r-- | server/lib/files-cache/videos-caption-cache.ts | 3 | ||||
-rw-r--r-- | server/lib/files-cache/videos-preview-cache.ts | 3 | ||||
-rw-r--r-- | server/lib/hls.ts | 3 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/activitypub-follow.ts | 4 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 5 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 3 | ||||
-rw-r--r-- | server/lib/job-queue/job-queue.ts | 4 | ||||
-rw-r--r-- | server/lib/notifier.ts | 2 | ||||
-rw-r--r-- | server/lib/oauth-model.ts | 3 | ||||
-rw-r--r-- | server/lib/redis.ts | 7 | ||||
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 7 | ||||
-rw-r--r-- | server/lib/video-blacklist.ts | 2 | ||||
-rw-r--r-- | server/lib/video-transcoding.ts | 7 |
21 files changed, 80 insertions, 65 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index c0ad07a52..cfefc26ce 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts | |||
@@ -12,7 +12,7 @@ import { logger } from '../../helpers/logger' | |||
12 | import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' | 12 | import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' |
13 | import { doRequest, downloadImage } from '../../helpers/requests' | 13 | import { doRequest, downloadImage } from '../../helpers/requests' |
14 | import { getUrlFromWebfinger } from '../../helpers/webfinger' | 14 | import { getUrlFromWebfinger } from '../../helpers/webfinger' |
15 | import { AVATARS_SIZE, CONFIG, MIMETYPES, sequelizeTypescript } from '../../initializers' | 15 | import { AVATARS_SIZE, MIMETYPES, sequelizeTypescript, WEBSERVER } from '../../initializers' |
16 | import { AccountModel } from '../../models/account/account' | 16 | import { AccountModel } from '../../models/account/account' |
17 | import { ActorModel } from '../../models/activitypub/actor' | 17 | import { ActorModel } from '../../models/activitypub/actor' |
18 | import { AvatarModel } from '../../models/avatar/avatar' | 18 | import { AvatarModel } from '../../models/avatar/avatar' |
@@ -21,6 +21,7 @@ import { VideoChannelModel } from '../../models/video/video-channel' | |||
21 | import { JobQueue } from '../job-queue' | 21 | import { JobQueue } from '../job-queue' |
22 | import { getServerActor } from '../../helpers/utils' | 22 | import { getServerActor } from '../../helpers/utils' |
23 | import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' | 23 | import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' |
24 | import { CONFIG } from '../../initializers/config' | ||
24 | 25 | ||
25 | // Set account keys, this could be long so process after the account creation and do not block the client | 26 | // Set account keys, this could be long so process after the account creation and do not block the client |
26 | function setAsyncActorKeys (actor: ActorModel) { | 27 | function setAsyncActorKeys (actor: ActorModel) { |
@@ -116,7 +117,7 @@ function buildActorInstance (type: ActivityPubActorType, url: string, preferredU | |||
116 | followingCount: 0, | 117 | followingCount: 0, |
117 | inboxUrl: url + '/inbox', | 118 | inboxUrl: url + '/inbox', |
118 | outboxUrl: url + '/outbox', | 119 | outboxUrl: url + '/outbox', |
119 | sharedInboxUrl: CONFIG.WEBSERVER.URL + '/inbox', | 120 | sharedInboxUrl: WEBSERVER.URL + '/inbox', |
120 | followersUrl: url + '/followers', | 121 | followersUrl: url + '/followers', |
121 | followingUrl: url + '/following' | 122 | followingUrl: url + '/following' |
122 | }) | 123 | }) |
diff --git a/server/lib/activitypub/playlist.ts b/server/lib/activitypub/playlist.ts index c4a8f12ec..a0d0e736e 100644 --- a/server/lib/activitypub/playlist.ts +++ b/server/lib/activitypub/playlist.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' | 1 | import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' |
2 | import { crawlCollectionPage } from './crawl' | 2 | import { crawlCollectionPage } from './crawl' |
3 | import { ACTIVITY_PUB, CONFIG, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers' | 3 | import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY, sequelizeTypescript, THUMBNAILS_SIZE } from '../../initializers' |
4 | import { AccountModel } from '../../models/account/account' | 4 | import { AccountModel } from '../../models/account/account' |
5 | import { isArray } from '../../helpers/custom-validators/misc' | 5 | import { isArray } from '../../helpers/custom-validators/misc' |
6 | import { getOrCreateActorAndServerAndModel } from './actor' | 6 | import { getOrCreateActorAndServerAndModel } from './actor' |
@@ -17,6 +17,7 @@ import { VideoModel } from '../../models/video/video' | |||
17 | import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' | 17 | import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' |
18 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' | 18 | import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' |
19 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' | 19 | import { ActivityIconObject } from '../../../shared/models/activitypub/objects' |
20 | import { CONFIG } from '../../initializers/config' | ||
20 | 21 | ||
21 | function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: AccountModel, to: string[]) { | 22 | function playlistObjectToDBAttributes (playlistObject: PlaylistObject, byAccount: AccountModel, to: string[]) { |
22 | const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPlaylistPrivacy.PUBLIC : VideoPlaylistPrivacy.UNLISTED | 23 | const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPlaylistPrivacy.PUBLIC : VideoPlaylistPrivacy.UNLISTED |
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index 276a57e60..ac3dd6ac4 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts | |||
@@ -1,13 +1,14 @@ | |||
1 | import { ActivityFollow } from '../../../../shared/models/activitypub' | 1 | import { ActivityFollow } from '../../../../shared/models/activitypub' |
2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { sequelizeTypescript, CONFIG } from '../../../initializers' | 4 | import { sequelizeTypescript } from '../../../initializers' |
5 | import { ActorModel } from '../../../models/activitypub/actor' | 5 | import { ActorModel } from '../../../models/activitypub/actor' |
6 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 6 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
7 | import { sendAccept, sendReject } from '../send' | 7 | import { sendAccept, sendReject } from '../send' |
8 | import { Notifier } from '../../notifier' | 8 | import { Notifier } from '../../notifier' |
9 | import { getAPId } from '../../../helpers/activitypub' | 9 | import { getAPId } from '../../../helpers/activitypub' |
10 | import { getServerActor } from '../../../helpers/utils' | 10 | import { getServerActor } from '../../../helpers/utils' |
11 | import { CONFIG } from '../../../initializers/config' | ||
11 | 12 | ||
12 | async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) { | 13 | async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) { |
13 | const activityObject = getAPId(activity.object) | 14 | const activityObject = getAPId(activity.object) |
diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts index 401b83fc2..01950a13b 100644 --- a/server/lib/activitypub/url.ts +++ b/server/lib/activitypub/url.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { CONFIG } from '../../initializers' | 1 | import { WEBSERVER } from '../../initializers' |
2 | import { ActorModel } from '../../models/activitypub/actor' | 2 | import { ActorModel } from '../../models/activitypub/actor' |
3 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | 3 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' |
4 | import { VideoModel } from '../../models/video/video' | 4 | import { VideoModel } from '../../models/video/video' |
@@ -9,41 +9,41 @@ import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming- | |||
9 | import { VideoPlaylistModel } from '../../models/video/video-playlist' | 9 | import { VideoPlaylistModel } from '../../models/video/video-playlist' |
10 | 10 | ||
11 | function getVideoActivityPubUrl (video: VideoModel) { | 11 | function getVideoActivityPubUrl (video: VideoModel) { |
12 | return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid | 12 | return WEBSERVER.URL + '/videos/watch/' + video.uuid |
13 | } | 13 | } |
14 | 14 | ||
15 | function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) { | 15 | function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) { |
16 | return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid | 16 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid |
17 | } | 17 | } |
18 | 18 | ||
19 | function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) { | 19 | function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) { |
20 | return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid | 20 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid |
21 | } | 21 | } |
22 | 22 | ||
23 | function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) { | 23 | function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) { |
24 | const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' | 24 | const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' |
25 | 25 | ||
26 | return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` | 26 | return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` |
27 | } | 27 | } |
28 | 28 | ||
29 | function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { | 29 | function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { |
30 | return `${CONFIG.WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` | 30 | return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` |
31 | } | 31 | } |
32 | 32 | ||
33 | function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { | 33 | function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { |
34 | return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id | 34 | return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id |
35 | } | 35 | } |
36 | 36 | ||
37 | function getVideoChannelActivityPubUrl (videoChannelName: string) { | 37 | function getVideoChannelActivityPubUrl (videoChannelName: string) { |
38 | return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName | 38 | return WEBSERVER.URL + '/video-channels/' + videoChannelName |
39 | } | 39 | } |
40 | 40 | ||
41 | function getAccountActivityPubUrl (accountName: string) { | 41 | function getAccountActivityPubUrl (accountName: string) { |
42 | return CONFIG.WEBSERVER.URL + '/accounts/' + accountName | 42 | return WEBSERVER.URL + '/accounts/' + accountName |
43 | } | 43 | } |
44 | 44 | ||
45 | function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) { | 45 | function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) { |
46 | return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id | 46 | return WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id |
47 | } | 47 | } |
48 | 48 | ||
49 | function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) { | 49 | function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) { |
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index caff0621e..191f4817b 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -19,7 +19,6 @@ import { logger } from '../../helpers/logger' | |||
19 | import { doRequest, downloadImage } from '../../helpers/requests' | 19 | import { doRequest, downloadImage } from '../../helpers/requests' |
20 | import { | 20 | import { |
21 | ACTIVITY_PUB, | 21 | ACTIVITY_PUB, |
22 | CONFIG, | ||
23 | MIMETYPES, | 22 | MIMETYPES, |
24 | P2P_MEDIA_LOADER_PEER_VERSION, | 23 | P2P_MEDIA_LOADER_PEER_VERSION, |
25 | REMOTE_SCHEME, | 24 | REMOTE_SCHEME, |
@@ -51,6 +50,7 @@ import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' | |||
51 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' | 50 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' |
52 | import { VideoShareModel } from '../../models/video/video-share' | 51 | import { VideoShareModel } from '../../models/video/video-share' |
53 | import { VideoCommentModel } from '../../models/video/video-comment' | 52 | import { VideoCommentModel } from '../../models/video/video-comment' |
53 | import { CONFIG } from '../../initializers/config' | ||
54 | 54 | ||
55 | async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { | 55 | async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) { |
56 | // If the video is not private and is published, we federate it | 56 | // If the video is not private and is published, we federate it |
diff --git a/server/lib/avatar.ts b/server/lib/avatar.ts index 021426a1a..a5316df4b 100644 --- a/server/lib/avatar.ts +++ b/server/lib/avatar.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import { sendUpdateActor } from './activitypub/send' | 2 | import { sendUpdateActor } from './activitypub/send' |
3 | import { AVATARS_SIZE, CONFIG, sequelizeTypescript } from '../initializers' | 3 | import { AVATARS_SIZE, sequelizeTypescript } from '../initializers' |
4 | import { updateActorAvatarInstance } from './activitypub' | 4 | import { updateActorAvatarInstance } from './activitypub' |
5 | import { processImage } from '../helpers/image-utils' | 5 | import { processImage } from '../helpers/image-utils' |
6 | import { AccountModel } from '../models/account/account' | 6 | import { AccountModel } from '../models/account/account' |
@@ -8,6 +8,7 @@ import { VideoChannelModel } from '../models/video/video-channel' | |||
8 | import { extname, join } from 'path' | 8 | import { extname, join } from 'path' |
9 | import { retryTransactionWrapper } from '../helpers/database-utils' | 9 | import { retryTransactionWrapper } from '../helpers/database-utils' |
10 | import * as uuidv4 from 'uuid/v4' | 10 | import * as uuidv4 from 'uuid/v4' |
11 | import { CONFIG } from '../initializers/config' | ||
11 | 12 | ||
12 | async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) { | 13 | async function updateActorAvatarFile (avatarPhysicalFile: Express.Multer.File, accountOrChannel: AccountModel | VideoChannelModel) { |
13 | const extension = extname(avatarPhysicalFile.filename) | 14 | const extension = extname(avatarPhysicalFile.filename) |
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 217f6a437..f8e1e456f 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' | 2 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' |
3 | import { CONFIG, CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE } from '../initializers' | 3 | import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, WEBSERVER } from '../initializers' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { escapeHTML } from '../helpers/core-utils' | 5 | import { escapeHTML } from '../helpers/core-utils' |
6 | import { VideoModel } from '../models/video/video' | 6 | import { VideoModel } from '../models/video/video' |
@@ -11,6 +11,7 @@ import { getActivityStreamDuration } from '../models/video/video-format-utils' | |||
11 | import { AccountModel } from '../models/account/account' | 11 | import { AccountModel } from '../models/account/account' |
12 | import { VideoChannelModel } from '../models/video/video-channel' | 12 | import { VideoChannelModel } from '../models/video/video-channel' |
13 | import * as Bluebird from 'bluebird' | 13 | import * as Bluebird from 'bluebird' |
14 | import { CONFIG } from '../initializers/config' | ||
14 | 15 | ||
15 | export class ClientHtml { | 16 | export class ClientHtml { |
16 | 17 | ||
@@ -106,7 +107,7 @@ export class ClientHtml { | |||
106 | 107 | ||
107 | // Save locale in cookies | 108 | // Save locale in cookies |
108 | res.cookie('clientLanguage', lang, { | 109 | res.cookie('clientLanguage', lang, { |
109 | secure: CONFIG.WEBSERVER.SCHEME === 'https', | 110 | secure: WEBSERVER.SCHEME === 'https', |
110 | sameSite: true, | 111 | sameSite: true, |
111 | maxAge: 1000 * 3600 * 24 * 90 // 3 months | 112 | maxAge: 1000 * 3600 * 24 * 90 // 3 months |
112 | }) | 113 | }) |
@@ -143,12 +144,12 @@ export class ClientHtml { | |||
143 | } | 144 | } |
144 | 145 | ||
145 | private static addVideoOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { | 146 | private static addVideoOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { |
146 | const previewUrl = CONFIG.WEBSERVER.URL + video.getPreviewStaticPath() | 147 | const previewUrl = WEBSERVER.URL + video.getPreviewStaticPath() |
147 | const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() | 148 | const videoUrl = WEBSERVER.URL + video.getWatchStaticPath() |
148 | 149 | ||
149 | const videoNameEscaped = escapeHTML(video.name) | 150 | const videoNameEscaped = escapeHTML(video.name) |
150 | const videoDescriptionEscaped = escapeHTML(video.description) | 151 | const videoDescriptionEscaped = escapeHTML(video.description) |
151 | const embedUrl = CONFIG.WEBSERVER.URL + video.getEmbedStaticPath() | 152 | const embedUrl = WEBSERVER.URL + video.getEmbedStaticPath() |
152 | 153 | ||
153 | const openGraphMetaTags = { | 154 | const openGraphMetaTags = { |
154 | 'og:type': 'video', | 155 | 'og:type': 'video', |
@@ -180,7 +181,7 @@ export class ClientHtml { | |||
180 | const oembedLinkTags = [ | 181 | const oembedLinkTags = [ |
181 | { | 182 | { |
182 | type: 'application/json+oembed', | 183 | type: 'application/json+oembed', |
183 | href: CONFIG.WEBSERVER.URL + '/services/oembed?url=' + encodeURIComponent(videoUrl), | 184 | href: WEBSERVER.URL + '/services/oembed?url=' + encodeURIComponent(videoUrl), |
184 | title: videoNameEscaped | 185 | title: videoNameEscaped |
185 | } | 186 | } |
186 | ] | 187 | ] |
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index aa9083362..8c06e9751 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { createTransport, Transporter } from 'nodemailer' | 1 | import { createTransport, Transporter } from 'nodemailer' |
2 | import { isTestInstance } from '../helpers/core-utils' | 2 | import { isTestInstance } from '../helpers/core-utils' |
3 | import { bunyanLogger, logger } from '../helpers/logger' | 3 | import { bunyanLogger, logger } from '../helpers/logger' |
4 | import { CONFIG } from '../initializers' | 4 | import { CONFIG } from '../initializers/config' |
5 | import { UserModel } from '../models/account/user' | 5 | import { UserModel } from '../models/account/user' |
6 | import { VideoModel } from '../models/video/video' | 6 | import { VideoModel } from '../models/video/video' |
7 | import { JobQueue } from './job-queue' | 7 | import { JobQueue } from './job-queue' |
@@ -12,6 +12,7 @@ import { VideoAbuseModel } from '../models/video/video-abuse' | |||
12 | import { VideoBlacklistModel } from '../models/video/video-blacklist' | 12 | import { VideoBlacklistModel } from '../models/video/video-blacklist' |
13 | import { VideoImportModel } from '../models/video/video-import' | 13 | import { VideoImportModel } from '../models/video/video-import' |
14 | import { ActorFollowModel } from '../models/activitypub/actor-follow' | 14 | import { ActorFollowModel } from '../models/activitypub/actor-follow' |
15 | import { WEBSERVER } from '../initializers/constants' | ||
15 | 16 | ||
16 | type SendEmailOptions = { | 17 | type SendEmailOptions = { |
17 | to: string[] | 18 | to: string[] |
@@ -91,7 +92,7 @@ class Emailer { | |||
91 | 92 | ||
92 | addNewVideoFromSubscriberNotification (to: string[], video: VideoModel) { | 93 | addNewVideoFromSubscriberNotification (to: string[], video: VideoModel) { |
93 | const channelName = video.VideoChannel.getDisplayName() | 94 | const channelName = video.VideoChannel.getDisplayName() |
94 | const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() | 95 | const videoUrl = WEBSERVER.URL + video.getWatchStaticPath() |
95 | 96 | ||
96 | const text = `Hi dear user,\n\n` + | 97 | const text = `Hi dear user,\n\n` + |
97 | `Your subscription ${channelName} just published a new video: ${video.name}` + | 98 | `Your subscription ${channelName} just published a new video: ${video.name}` + |
@@ -148,7 +149,7 @@ class Emailer { | |||
148 | } | 149 | } |
149 | 150 | ||
150 | myVideoPublishedNotification (to: string[], video: VideoModel) { | 151 | myVideoPublishedNotification (to: string[], video: VideoModel) { |
151 | const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() | 152 | const videoUrl = WEBSERVER.URL + video.getWatchStaticPath() |
152 | 153 | ||
153 | const text = `Hi dear user,\n\n` + | 154 | const text = `Hi dear user,\n\n` + |
154 | `Your video ${video.name} has been published.` + | 155 | `Your video ${video.name} has been published.` + |
@@ -168,7 +169,7 @@ class Emailer { | |||
168 | } | 169 | } |
169 | 170 | ||
170 | myVideoImportSuccessNotification (to: string[], videoImport: VideoImportModel) { | 171 | myVideoImportSuccessNotification (to: string[], videoImport: VideoImportModel) { |
171 | const videoUrl = CONFIG.WEBSERVER.URL + videoImport.Video.getWatchStaticPath() | 172 | const videoUrl = WEBSERVER.URL + videoImport.Video.getWatchStaticPath() |
172 | 173 | ||
173 | const text = `Hi dear user,\n\n` + | 174 | const text = `Hi dear user,\n\n` + |
174 | `Your video import ${videoImport.getTargetIdentifier()} is finished.` + | 175 | `Your video import ${videoImport.getTargetIdentifier()} is finished.` + |
@@ -188,7 +189,7 @@ class Emailer { | |||
188 | } | 189 | } |
189 | 190 | ||
190 | myVideoImportErrorNotification (to: string[], videoImport: VideoImportModel) { | 191 | myVideoImportErrorNotification (to: string[], videoImport: VideoImportModel) { |
191 | const importUrl = CONFIG.WEBSERVER.URL + '/my-account/video-imports' | 192 | const importUrl = WEBSERVER.URL + '/my-account/video-imports' |
192 | 193 | ||
193 | const text = `Hi dear user,\n\n` + | 194 | const text = `Hi dear user,\n\n` + |
194 | `Your video import ${videoImport.getTargetIdentifier()} encountered an error.` + | 195 | `Your video import ${videoImport.getTargetIdentifier()} encountered an error.` + |
@@ -210,7 +211,7 @@ class Emailer { | |||
210 | addNewCommentOnMyVideoNotification (to: string[], comment: VideoCommentModel) { | 211 | addNewCommentOnMyVideoNotification (to: string[], comment: VideoCommentModel) { |
211 | const accountName = comment.Account.getDisplayName() | 212 | const accountName = comment.Account.getDisplayName() |
212 | const video = comment.Video | 213 | const video = comment.Video |
213 | const commentUrl = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath() | 214 | const commentUrl = WEBSERVER.URL + comment.getCommentStaticPath() |
214 | 215 | ||
215 | const text = `Hi dear user,\n\n` + | 216 | const text = `Hi dear user,\n\n` + |
216 | `A new comment has been posted by ${accountName} on your video ${video.name}` + | 217 | `A new comment has been posted by ${accountName} on your video ${video.name}` + |
@@ -232,7 +233,7 @@ class Emailer { | |||
232 | addNewCommentMentionNotification (to: string[], comment: VideoCommentModel) { | 233 | addNewCommentMentionNotification (to: string[], comment: VideoCommentModel) { |
233 | const accountName = comment.Account.getDisplayName() | 234 | const accountName = comment.Account.getDisplayName() |
234 | const video = comment.Video | 235 | const video = comment.Video |
235 | const commentUrl = CONFIG.WEBSERVER.URL + comment.getCommentStaticPath() | 236 | const commentUrl = WEBSERVER.URL + comment.getCommentStaticPath() |
236 | 237 | ||
237 | const text = `Hi dear user,\n\n` + | 238 | const text = `Hi dear user,\n\n` + |
238 | `${accountName} mentioned you on video ${video.name}` + | 239 | `${accountName} mentioned you on video ${video.name}` + |
@@ -252,10 +253,10 @@ class Emailer { | |||
252 | } | 253 | } |
253 | 254 | ||
254 | addVideoAbuseModeratorsNotification (to: string[], videoAbuse: VideoAbuseModel) { | 255 | addVideoAbuseModeratorsNotification (to: string[], videoAbuse: VideoAbuseModel) { |
255 | const videoUrl = CONFIG.WEBSERVER.URL + videoAbuse.Video.getWatchStaticPath() | 256 | const videoUrl = WEBSERVER.URL + videoAbuse.Video.getWatchStaticPath() |
256 | 257 | ||
257 | const text = `Hi,\n\n` + | 258 | const text = `Hi,\n\n` + |
258 | `${CONFIG.WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` + | 259 | `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` + |
259 | `Cheers,\n` + | 260 | `Cheers,\n` + |
260 | `PeerTube.` | 261 | `PeerTube.` |
261 | 262 | ||
@@ -269,8 +270,8 @@ class Emailer { | |||
269 | } | 270 | } |
270 | 271 | ||
271 | addVideoAutoBlacklistModeratorsNotification (to: string[], video: VideoModel) { | 272 | addVideoAutoBlacklistModeratorsNotification (to: string[], video: VideoModel) { |
272 | const VIDEO_AUTO_BLACKLIST_URL = CONFIG.WEBSERVER.URL + '/admin/moderation/video-auto-blacklist/list' | 273 | const VIDEO_AUTO_BLACKLIST_URL = WEBSERVER.URL + '/admin/moderation/video-auto-blacklist/list' |
273 | const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() | 274 | const videoUrl = WEBSERVER.URL + video.getWatchStaticPath() |
274 | 275 | ||
275 | const text = `Hi,\n\n` + | 276 | const text = `Hi,\n\n` + |
276 | `A recently added video was auto-blacklisted and requires moderator review before publishing.` + | 277 | `A recently added video was auto-blacklisted and requires moderator review before publishing.` + |
@@ -293,13 +294,13 @@ class Emailer { | |||
293 | 294 | ||
294 | addNewUserRegistrationNotification (to: string[], user: UserModel) { | 295 | addNewUserRegistrationNotification (to: string[], user: UserModel) { |
295 | const text = `Hi,\n\n` + | 296 | const text = `Hi,\n\n` + |
296 | `User ${user.username} just registered on ${CONFIG.WEBSERVER.HOST} PeerTube instance.\n\n` + | 297 | `User ${user.username} just registered on ${WEBSERVER.HOST} PeerTube instance.\n\n` + |
297 | `Cheers,\n` + | 298 | `Cheers,\n` + |
298 | `PeerTube.` | 299 | `PeerTube.` |
299 | 300 | ||
300 | const emailPayload: EmailPayload = { | 301 | const emailPayload: EmailPayload = { |
301 | to, | 302 | to, |
302 | subject: '[PeerTube] New user registration on ' + CONFIG.WEBSERVER.HOST, | 303 | subject: '[PeerTube] New user registration on ' + WEBSERVER.HOST, |
303 | text | 304 | text |
304 | } | 305 | } |
305 | 306 | ||
@@ -308,10 +309,10 @@ class Emailer { | |||
308 | 309 | ||
309 | addVideoBlacklistNotification (to: string[], videoBlacklist: VideoBlacklistModel) { | 310 | addVideoBlacklistNotification (to: string[], videoBlacklist: VideoBlacklistModel) { |
310 | const videoName = videoBlacklist.Video.name | 311 | const videoName = videoBlacklist.Video.name |
311 | const videoUrl = CONFIG.WEBSERVER.URL + videoBlacklist.Video.getWatchStaticPath() | 312 | const videoUrl = WEBSERVER.URL + videoBlacklist.Video.getWatchStaticPath() |
312 | 313 | ||
313 | const reasonString = videoBlacklist.reason ? ` for the following reason: ${videoBlacklist.reason}` : '' | 314 | const reasonString = videoBlacklist.reason ? ` for the following reason: ${videoBlacklist.reason}` : '' |
314 | const blockedString = `Your video ${videoName} (${videoUrl} on ${CONFIG.WEBSERVER.HOST} has been blacklisted${reasonString}.` | 315 | const blockedString = `Your video ${videoName} (${videoUrl} on ${WEBSERVER.HOST} has been blacklisted${reasonString}.` |
315 | 316 | ||
316 | const text = 'Hi,\n\n' + | 317 | const text = 'Hi,\n\n' + |
317 | blockedString + | 318 | blockedString + |
@@ -329,10 +330,10 @@ class Emailer { | |||
329 | } | 330 | } |
330 | 331 | ||
331 | addVideoUnblacklistNotification (to: string[], video: VideoModel) { | 332 | addVideoUnblacklistNotification (to: string[], video: VideoModel) { |
332 | const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath() | 333 | const videoUrl = WEBSERVER.URL + video.getWatchStaticPath() |
333 | 334 | ||
334 | const text = 'Hi,\n\n' + | 335 | const text = 'Hi,\n\n' + |
335 | `Your video ${video.name} (${videoUrl}) on ${CONFIG.WEBSERVER.HOST} has been unblacklisted.` + | 336 | `Your video ${video.name} (${videoUrl}) on ${WEBSERVER.HOST} has been unblacklisted.` + |
336 | '\n\n' + | 337 | '\n\n' + |
337 | 'Cheers,\n' + | 338 | 'Cheers,\n' + |
338 | `PeerTube.` | 339 | `PeerTube.` |
@@ -348,7 +349,7 @@ class Emailer { | |||
348 | 349 | ||
349 | addPasswordResetEmailJob (to: string, resetPasswordUrl: string) { | 350 | addPasswordResetEmailJob (to: string, resetPasswordUrl: string) { |
350 | const text = `Hi dear user,\n\n` + | 351 | const text = `Hi dear user,\n\n` + |
351 | `A reset password procedure for your account ${to} has been requested on ${CONFIG.WEBSERVER.HOST} ` + | 352 | `A reset password procedure for your account ${to} has been requested on ${WEBSERVER.HOST} ` + |
352 | `Please follow this link to reset it: ${resetPasswordUrl}\n\n` + | 353 | `Please follow this link to reset it: ${resetPasswordUrl}\n\n` + |
353 | `If you are not the person who initiated this request, please ignore this email.\n\n` + | 354 | `If you are not the person who initiated this request, please ignore this email.\n\n` + |
354 | `Cheers,\n` + | 355 | `Cheers,\n` + |
@@ -365,7 +366,7 @@ class Emailer { | |||
365 | 366 | ||
366 | addVerifyEmailJob (to: string, verifyEmailUrl: string) { | 367 | addVerifyEmailJob (to: string, verifyEmailUrl: string) { |
367 | const text = `Welcome to PeerTube,\n\n` + | 368 | const text = `Welcome to PeerTube,\n\n` + |
368 | `To start using PeerTube on ${CONFIG.WEBSERVER.HOST} you must verify your email! ` + | 369 | `To start using PeerTube on ${WEBSERVER.HOST} you must verify your email! ` + |
369 | `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` + | 370 | `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` + |
370 | `If you are not the person who initiated this request, please ignore this email.\n\n` + | 371 | `If you are not the person who initiated this request, please ignore this email.\n\n` + |
371 | `Cheers,\n` + | 372 | `Cheers,\n` + |
@@ -383,7 +384,7 @@ class Emailer { | |||
383 | addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) { | 384 | addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) { |
384 | const reasonString = reason ? ` for the following reason: ${reason}` : '' | 385 | const reasonString = reason ? ` for the following reason: ${reason}` : '' |
385 | const blockedWord = blocked ? 'blocked' : 'unblocked' | 386 | const blockedWord = blocked ? 'blocked' : 'unblocked' |
386 | const blockedString = `Your account ${user.username} on ${CONFIG.WEBSERVER.HOST} has been ${blockedWord}${reasonString}.` | 387 | const blockedString = `Your account ${user.username} on ${WEBSERVER.HOST} has been ${blockedWord}${reasonString}.` |
387 | 388 | ||
388 | const text = 'Hi,\n\n' + | 389 | const text = 'Hi,\n\n' + |
389 | blockedString + | 390 | blockedString + |
@@ -428,7 +429,7 @@ class Emailer { | |||
428 | 429 | ||
429 | const fromDisplayName = options.fromDisplayName | 430 | const fromDisplayName = options.fromDisplayName |
430 | ? options.fromDisplayName | 431 | ? options.fromDisplayName |
431 | : CONFIG.WEBSERVER.HOST | 432 | : WEBSERVER.HOST |
432 | 433 | ||
433 | return this.transporter.sendMail({ | 434 | return this.transporter.sendMail({ |
434 | from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`, | 435 | from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`, |
diff --git a/server/lib/files-cache/videos-caption-cache.ts b/server/lib/files-cache/videos-caption-cache.ts index fe5b441af..f5ccfe0a2 100644 --- a/server/lib/files-cache/videos-caption-cache.ts +++ b/server/lib/files-cache/videos-caption-cache.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { FILES_CACHE, CONFIG } from '../../initializers' | 2 | import { FILES_CACHE } from '../../initializers' |
3 | import { VideoModel } from '../../models/video/video' | 3 | import { VideoModel } from '../../models/video/video' |
4 | import { VideoCaptionModel } from '../../models/video/video-caption' | 4 | import { VideoCaptionModel } from '../../models/video/video-caption' |
5 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' | 5 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' |
6 | import { CONFIG } from '../../initializers/config' | ||
6 | 7 | ||
7 | type GetPathParam = { videoId: string, language: string } | 8 | type GetPathParam = { videoId: string, language: string } |
8 | 9 | ||
diff --git a/server/lib/files-cache/videos-preview-cache.ts b/server/lib/files-cache/videos-preview-cache.ts index 01cd3647e..192f99aec 100644 --- a/server/lib/files-cache/videos-preview-cache.ts +++ b/server/lib/files-cache/videos-preview-cache.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { FILES_CACHE, CONFIG, STATIC_PATHS } from '../../initializers' | 2 | import { FILES_CACHE, STATIC_PATHS } from '../../initializers' |
3 | import { VideoModel } from '../../models/video/video' | 3 | import { VideoModel } from '../../models/video/video' |
4 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' | 4 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' |
5 | import { CONFIG } from '../../initializers/config' | ||
5 | 6 | ||
6 | class VideosPreviewCache extends AbstractVideoStaticFileCache <string> { | 7 | class VideosPreviewCache extends AbstractVideoStaticFileCache <string> { |
7 | 8 | ||
diff --git a/server/lib/hls.ts b/server/lib/hls.ts index a9a96dd16..e804e7b3a 100644 --- a/server/lib/hls.ts +++ b/server/lib/hls.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { VideoModel } from '../models/video/video' | 1 | import { VideoModel } from '../models/video/video' |
2 | import { basename, dirname, join } from 'path' | 2 | import { basename, dirname, join } from 'path' |
3 | import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers' | 3 | import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, sequelizeTypescript } from '../initializers' |
4 | import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' | 4 | import { close, ensureDir, move, open, outputJSON, pathExists, read, readFile, remove, writeFile } from 'fs-extra' |
5 | import { getVideoFileSize } from '../helpers/ffmpeg-utils' | 5 | import { getVideoFileSize } from '../helpers/ffmpeg-utils' |
6 | import { sha256 } from '../helpers/core-utils' | 6 | import { sha256 } from '../helpers/core-utils' |
@@ -10,6 +10,7 @@ import { doRequest, doRequestAndSaveToFile } from '../helpers/requests' | |||
10 | import { generateRandomString } from '../helpers/utils' | 10 | import { generateRandomString } from '../helpers/utils' |
11 | import { flatten, uniq } from 'lodash' | 11 | import { flatten, uniq } from 'lodash' |
12 | import { VideoFileModel } from '../models/video/video-file' | 12 | import { VideoFileModel } from '../models/video/video-file' |
13 | import { CONFIG } from '../initializers/config' | ||
13 | 14 | ||
14 | async function updateStreamingPlaylistsInfohashesIfNeeded () { | 15 | async function updateStreamingPlaylistsInfohashesIfNeeded () { |
15 | const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion() | 16 | const playlistsToUpdate = await VideoStreamingPlaylistModel.listByIncorrectPeerVersion() |
diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index e7e5ff950..7c84aa937 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as Bull from 'bull' | 1 | import * as Bull from 'bull' |
2 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
3 | import { CONFIG, REMOTE_SCHEME, sequelizeTypescript } from '../../../initializers' | 3 | import { REMOTE_SCHEME, sequelizeTypescript, WEBSERVER } from '../../../initializers' |
4 | import { sendFollow } from '../../activitypub/send' | 4 | import { sendFollow } from '../../activitypub/send' |
5 | import { sanitizeHost } from '../../../helpers/core-utils' | 5 | import { sanitizeHost } from '../../../helpers/core-utils' |
6 | import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' | 6 | import { loadActorUrlOrGetFromWebfinger } from '../../../helpers/webfinger' |
@@ -23,7 +23,7 @@ async function processActivityPubFollow (job: Bull.Job) { | |||
23 | logger.info('Processing ActivityPub follow in job %d.', job.id) | 23 | logger.info('Processing ActivityPub follow in job %d.', job.id) |
24 | 24 | ||
25 | let targetActor: ActorModel | 25 | let targetActor: ActorModel |
26 | if (!host || host === CONFIG.WEBSERVER.HOST) { | 26 | if (!host || host === WEBSERVER.HOST) { |
27 | targetActor = await ActorModel.loadLocalByName(payload.name) | 27 | targetActor = await ActorModel.loadLocalByName(payload.name) |
28 | } else { | 28 | } else { |
29 | const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP) | 29 | const sanitizedHost = sanitizeHost(host, REMOTE_SCHEME.HTTP) |
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index c5fc1061c..732773efd 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -6,7 +6,7 @@ import { VideoImportState } from '../../../../shared/models/videos' | |||
6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' | 6 | import { getDurationFromVideoFile, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' |
7 | import { extname, join } from 'path' | 7 | import { extname, join } from 'path' |
8 | import { VideoFileModel } from '../../../models/video/video-file' | 8 | import { VideoFileModel } from '../../../models/video/video-file' |
9 | import { CONFIG, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' | 9 | import { PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE, VIDEO_IMPORT_TIMEOUT } from '../../../initializers' |
10 | import { downloadImage } from '../../../helpers/requests' | 10 | import { downloadImage } from '../../../helpers/requests' |
11 | import { VideoState } from '../../../../shared' | 11 | import { VideoState } from '../../../../shared' |
12 | import { JobQueue } from '../index' | 12 | import { JobQueue } from '../index' |
@@ -14,8 +14,9 @@ import { federateVideoIfNeeded } from '../../activitypub' | |||
14 | import { VideoModel } from '../../../models/video/video' | 14 | import { VideoModel } from '../../../models/video/video' |
15 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' | 15 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' |
16 | import { getSecureTorrentName } from '../../../helpers/utils' | 16 | import { getSecureTorrentName } from '../../../helpers/utils' |
17 | import { remove, move, stat } from 'fs-extra' | 17 | import { move, remove, stat } from 'fs-extra' |
18 | import { Notifier } from '../../notifier' | 18 | import { Notifier } from '../../notifier' |
19 | import { CONFIG } from '../../../initializers/config' | ||
19 | 20 | ||
20 | type VideoImportYoutubeDLPayload = { | 21 | type VideoImportYoutubeDLPayload = { |
21 | type: 'youtube-dl' | 22 | type: 'youtube-dl' |
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 581ec283e..48cac517e 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -5,11 +5,12 @@ import { VideoModel } from '../../../models/video/video' | |||
5 | import { JobQueue } from '../job-queue' | 5 | import { JobQueue } from '../job-queue' |
6 | import { federateVideoIfNeeded } from '../../activitypub' | 6 | import { federateVideoIfNeeded } from '../../activitypub' |
7 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 7 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
8 | import { CONFIG, sequelizeTypescript } from '../../../initializers' | 8 | import { sequelizeTypescript } from '../../../initializers' |
9 | import * as Bluebird from 'bluebird' | 9 | import * as Bluebird from 'bluebird' |
10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' | 10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' |
11 | import { generateHlsPlaylist, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding' | 11 | import { generateHlsPlaylist, optimizeVideofile, transcodeOriginalVideofile } from '../../video-transcoding' |
12 | import { Notifier } from '../../notifier' | 12 | import { Notifier } from '../../notifier' |
13 | import { CONFIG } from '../../../initializers/config' | ||
13 | 14 | ||
14 | export type VideoTranscodingPayload = { | 15 | export type VideoTranscodingPayload = { |
15 | videoUUID: string | 16 | videoUUID: string |
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index cee0941c7..1c2aa109d 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts | |||
@@ -2,7 +2,7 @@ import * as Bull from 'bull' | |||
2 | import { JobState, JobType } from '../../../shared/models' | 2 | import { JobState, JobType } from '../../../shared/models' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { Redis } from '../redis' | 4 | import { Redis } from '../redis' |
5 | import { CONFIG, JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS } from '../../initializers' | 5 | import { JOB_ATTEMPTS, JOB_COMPLETED_LIFETIME, JOB_CONCURRENCY, JOB_TTL, REPEAT_JOBS, WEBSERVER } from '../../initializers' |
6 | import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' | 6 | import { ActivitypubHttpBroadcastPayload, processActivityPubHttpBroadcast } from './handlers/activitypub-http-broadcast' |
7 | import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' | 7 | import { ActivitypubHttpFetcherPayload, processActivityPubHttpFetcher } from './handlers/activitypub-http-fetcher' |
8 | import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' | 8 | import { ActivitypubHttpUnicastPayload, processActivityPubHttpUnicast } from './handlers/activitypub-http-unicast' |
@@ -68,7 +68,7 @@ class JobQueue { | |||
68 | if (this.initialized === true) return | 68 | if (this.initialized === true) return |
69 | this.initialized = true | 69 | this.initialized = true |
70 | 70 | ||
71 | this.jobRedisPrefix = 'bull-' + CONFIG.WEBSERVER.HOST | 71 | this.jobRedisPrefix = 'bull-' + WEBSERVER.HOST |
72 | const queueOptions = { | 72 | const queueOptions = { |
73 | prefix: this.jobRedisPrefix, | 73 | prefix: this.jobRedisPrefix, |
74 | redis: Redis.getRedisClient(), | 74 | redis: Redis.getRedisClient(), |
diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts index 91b71cc64..c1e63fa8f 100644 --- a/server/lib/notifier.ts +++ b/server/lib/notifier.ts | |||
@@ -6,7 +6,7 @@ import { UserNotificationModel } from '../models/account/user-notification' | |||
6 | import { VideoCommentModel } from '../models/video/video-comment' | 6 | import { VideoCommentModel } from '../models/video/video-comment' |
7 | import { UserModel } from '../models/account/user' | 7 | import { UserModel } from '../models/account/user' |
8 | import { PeerTubeSocket } from './peertube-socket' | 8 | import { PeerTubeSocket } from './peertube-socket' |
9 | import { CONFIG } from '../initializers/constants' | 9 | import { CONFIG } from '../initializers/config' |
10 | import { VideoPrivacy, VideoState } from '../../shared/models/videos' | 10 | import { VideoPrivacy, VideoState } from '../../shared/models/videos' |
11 | import { VideoAbuseModel } from '../models/video/video-abuse' | 11 | import { VideoAbuseModel } from '../models/video/video-abuse' |
12 | import { VideoBlacklistModel } from '../models/video/video-blacklist' | 12 | import { VideoBlacklistModel } from '../models/video/video-blacklist' |
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts index 5b4a2bcf9..eb0e63bc8 100644 --- a/server/lib/oauth-model.ts +++ b/server/lib/oauth-model.ts | |||
@@ -4,8 +4,9 @@ import { logger } from '../helpers/logger' | |||
4 | import { UserModel } from '../models/account/user' | 4 | import { UserModel } from '../models/account/user' |
5 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 5 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
6 | import { OAuthTokenModel } from '../models/oauth/oauth-token' | 6 | import { OAuthTokenModel } from '../models/oauth/oauth-token' |
7 | import { CONFIG, CACHE } from '../initializers/constants' | 7 | import { CACHE } from '../initializers/constants' |
8 | import { Transaction } from 'sequelize' | 8 | import { Transaction } from 'sequelize' |
9 | import { CONFIG } from '../initializers/config' | ||
9 | 10 | ||
10 | type TokenInfo = { accessToken: string, refreshToken: string, accessTokenExpiresAt: Date, refreshTokenExpiresAt: Date } | 11 | type TokenInfo = { accessToken: string, refreshToken: string, accessTokenExpiresAt: Date, refreshTokenExpiresAt: Date } |
11 | let accessTokenCache: { [ accessToken: string ]: OAuthTokenModel } = {} | 12 | let accessTokenCache: { [ accessToken: string ]: OAuthTokenModel } = {} |
diff --git a/server/lib/redis.ts b/server/lib/redis.ts index d85dbe2b5..a7ec8c9df 100644 --- a/server/lib/redis.ts +++ b/server/lib/redis.ts | |||
@@ -3,12 +3,13 @@ import { createClient, RedisClient } from 'redis' | |||
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | import { generateRandomString } from '../helpers/utils' | 4 | import { generateRandomString } from '../helpers/utils' |
5 | import { | 5 | import { |
6 | CONFIG, | ||
7 | CONTACT_FORM_LIFETIME, | 6 | CONTACT_FORM_LIFETIME, |
8 | USER_EMAIL_VERIFY_LIFETIME, | 7 | USER_EMAIL_VERIFY_LIFETIME, |
9 | USER_PASSWORD_RESET_LIFETIME, | 8 | USER_PASSWORD_RESET_LIFETIME, |
10 | VIDEO_VIEW_LIFETIME | 9 | VIDEO_VIEW_LIFETIME, |
10 | WEBSERVER | ||
11 | } from '../initializers' | 11 | } from '../initializers' |
12 | import { CONFIG } from '../initializers/config' | ||
12 | 13 | ||
13 | type CachedRoute = { | 14 | type CachedRoute = { |
14 | body: string, | 15 | body: string, |
@@ -41,7 +42,7 @@ class Redis { | |||
41 | this.client.auth(CONFIG.REDIS.AUTH) | 42 | this.client.auth(CONFIG.REDIS.AUTH) |
42 | } | 43 | } |
43 | 44 | ||
44 | this.prefix = 'redis-' + CONFIG.WEBSERVER.HOST + '-' | 45 | this.prefix = 'redis-' + WEBSERVER.HOST + '-' |
45 | } | 46 | } |
46 | 47 | ||
47 | static getRedisClient () { | 48 | static getRedisClient () { |
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 1a48f2bd0..4a8a1d413 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { AbstractScheduler } from './abstract-scheduler' | 1 | import { AbstractScheduler } from './abstract-scheduler' |
2 | import { CONFIG, HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT } from '../../initializers' | 2 | import { HLS_REDUNDANCY_DIRECTORY, REDUNDANCY, VIDEO_IMPORT_TIMEOUT, WEBSERVER } from '../../initializers' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { VideosRedundancy } from '../../../shared/models/redundancy' | 4 | import { VideosRedundancy } from '../../../shared/models/redundancy' |
5 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' | 5 | import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' |
@@ -15,6 +15,7 @@ import { getOrCreateVideoAndAccountAndChannel } from '../activitypub' | |||
15 | import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist' | 15 | import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist' |
16 | import { VideoModel } from '../../models/video/video' | 16 | import { VideoModel } from '../../models/video/video' |
17 | import { downloadPlaylistSegments } from '../hls' | 17 | import { downloadPlaylistSegments } from '../hls' |
18 | import { CONFIG } from '../../initializers/config' | ||
18 | 19 | ||
19 | type CandidateToDuplicate = { | 20 | type CandidateToDuplicate = { |
20 | redundancy: VideosRedundancy, | 21 | redundancy: VideosRedundancy, |
@@ -186,7 +187,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
186 | const createdModel = await VideoRedundancyModel.create({ | 187 | const createdModel = await VideoRedundancyModel.create({ |
187 | expiresOn: this.buildNewExpiration(redundancy.minLifetime), | 188 | expiresOn: this.buildNewExpiration(redundancy.minLifetime), |
188 | url: getVideoCacheFileActivityPubUrl(file), | 189 | url: getVideoCacheFileActivityPubUrl(file), |
189 | fileUrl: video.getVideoRedundancyUrl(file, CONFIG.WEBSERVER.URL), | 190 | fileUrl: video.getVideoRedundancyUrl(file, WEBSERVER.URL), |
190 | strategy: redundancy.strategy, | 191 | strategy: redundancy.strategy, |
191 | videoFileId: file.id, | 192 | videoFileId: file.id, |
192 | actorId: serverActor.id | 193 | actorId: serverActor.id |
@@ -212,7 +213,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler { | |||
212 | const createdModel = await VideoRedundancyModel.create({ | 213 | const createdModel = await VideoRedundancyModel.create({ |
213 | expiresOn: this.buildNewExpiration(redundancy.minLifetime), | 214 | expiresOn: this.buildNewExpiration(redundancy.minLifetime), |
214 | url: getVideoCacheStreamingPlaylistActivityPubUrl(video, playlist), | 215 | url: getVideoCacheStreamingPlaylistActivityPubUrl(video, playlist), |
215 | fileUrl: playlist.getVideoRedundancyUrl(CONFIG.WEBSERVER.URL), | 216 | fileUrl: playlist.getVideoRedundancyUrl(WEBSERVER.URL), |
216 | strategy: redundancy.strategy, | 217 | strategy: redundancy.strategy, |
217 | videoStreamingPlaylistId: playlist.id, | 218 | videoStreamingPlaylistId: playlist.id, |
218 | actorId: serverActor.id | 219 | actorId: serverActor.id |
diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts index dc4e0aed9..a5c6fcbb2 100644 --- a/server/lib/video-blacklist.ts +++ b/server/lib/video-blacklist.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as sequelize from 'sequelize' | 1 | import * as sequelize from 'sequelize' |
2 | import { CONFIG } from '../initializers/constants' | 2 | import { CONFIG } from '../initializers/config' |
3 | import { VideoBlacklistType, UserRight } from '../../shared/models' | 3 | import { VideoBlacklistType, UserRight } from '../../shared/models' |
4 | import { VideoBlacklistModel } from '../models/video/video-blacklist' | 4 | import { VideoBlacklistModel } from '../models/video/video-blacklist' |
5 | import { UserModel } from '../models/account/user' | 5 | import { UserModel } from '../models/account/user' |
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index dbc22816c..11098dca3 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { CONFIG, HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION } from '../initializers' | 1 | import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' | 3 | import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' |
4 | import { ensureDir, move, remove, stat } from 'fs-extra' | 4 | import { ensureDir, move, remove, stat } from 'fs-extra' |
@@ -9,6 +9,7 @@ import { VideoModel } from '../models/video/video' | |||
9 | import { updateMasterHLSPlaylist, updateSha256Segments } from './hls' | 9 | import { updateMasterHLSPlaylist, updateSha256Segments } from './hls' |
10 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' | 10 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' |
11 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' | 11 | import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' |
12 | import { CONFIG } from '../initializers/config' | ||
12 | 13 | ||
13 | async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { | 14 | async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { |
14 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR | 15 | const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR |
@@ -111,12 +112,12 @@ async function generateHlsPlaylist (video: VideoModel, resolution: VideoResoluti | |||
111 | await updateMasterHLSPlaylist(video) | 112 | await updateMasterHLSPlaylist(video) |
112 | await updateSha256Segments(video) | 113 | await updateSha256Segments(video) |
113 | 114 | ||
114 | const playlistUrl = CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) | 115 | const playlistUrl = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) |
115 | 116 | ||
116 | await VideoStreamingPlaylistModel.upsert({ | 117 | await VideoStreamingPlaylistModel.upsert({ |
117 | videoId: video.id, | 118 | videoId: video.id, |
118 | playlistUrl, | 119 | playlistUrl, |
119 | segmentsSha256Url: CONFIG.WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid), | 120 | segmentsSha256Url: WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid), |
120 | p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, video.VideoFiles), | 121 | p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, video.VideoFiles), |
121 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, | 122 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, |
122 | 123 | ||