aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/checker-after-init.ts2
-rw-r--r--server/initializers/constants.ts11
-rw-r--r--server/initializers/database.ts18
-rw-r--r--server/initializers/installer.ts7
-rw-r--r--server/initializers/migrations/0645-actor-remote-creation-date.ts26
-rw-r--r--server/initializers/migrations/0650-actor-custom-pages.ts33
6 files changed, 83 insertions, 14 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts
index a93c8b7fd..911734fa0 100644
--- a/server/initializers/checker-after-init.ts
+++ b/server/initializers/checker-after-init.ts
@@ -7,7 +7,7 @@ import { RecentlyAddedStrategy } from '../../shared/models/redundancy'
7import { isProdInstance, isTestInstance, parseSemVersion } from '../helpers/core-utils' 7import { isProdInstance, isTestInstance, parseSemVersion } from '../helpers/core-utils'
8import { isArray } from '../helpers/custom-validators/misc' 8import { isArray } from '../helpers/custom-validators/misc'
9import { logger } from '../helpers/logger' 9import { logger } from '../helpers/logger'
10import { UserModel } from '../models/account/user' 10import { UserModel } from '../models/user/user'
11import { ApplicationModel, getServerActor } from '../models/application/application' 11import { ApplicationModel, getServerActor } from '../models/application/application'
12import { OAuthClientModel } from '../models/oauth/oauth-client' 12import { OAuthClientModel } from '../models/oauth/oauth-client'
13import { CONFIG, isEmailEnabled } from './config' 13import { CONFIG, isEmailEnabled } from './config'
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index d390fd95e..919f9ea6e 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
24 24
25// --------------------------------------------------------------------------- 25// ---------------------------------------------------------------------------
26 26
27const LAST_MIGRATION_VERSION = 640 27const LAST_MIGRATION_VERSION = 650
28 28
29// --------------------------------------------------------------------------- 29// ---------------------------------------------------------------------------
30 30
@@ -208,7 +208,8 @@ const SCHEDULER_INTERVALS_MS = {
208 autoFollowIndexInstances: 60000 * 60 * 24, // 1 day 208 autoFollowIndexInstances: 60000 * 60 * 24, // 1 day
209 removeOldViews: 60000 * 60 * 24, // 1 day 209 removeOldViews: 60000 * 60 * 24, // 1 day
210 removeOldHistory: 60000 * 60 * 24, // 1 day 210 removeOldHistory: 60000 * 60 * 24, // 1 day
211 updateInboxStats: 1000 * 60// 1 minute 211 updateInboxStats: 1000 * 60, // 1 minute
212 removeDanglingResumableUploads: 60000 * 60 * 16 // 16 hours
212} 213}
213 214
214// --------------------------------------------------------------------------- 215// ---------------------------------------------------------------------------
@@ -285,6 +286,7 @@ const CONSTRAINTS_FIELDS = {
285 LIKES: { min: 0 }, 286 LIKES: { min: 0 },
286 DISLIKES: { min: 0 }, 287 DISLIKES: { min: 0 },
287 FILE_SIZE: { min: -1 }, 288 FILE_SIZE: { min: -1 },
289 PARTIAL_UPLOAD_SIZE: { max: 50 * 1024 * 1024 * 1024 }, // 50GB
288 URL: { min: 3, max: 2000 } // Length 290 URL: { min: 3, max: 2000 } // Length
289 }, 291 },
290 VIDEO_PLAYLISTS: { 292 VIDEO_PLAYLISTS: {
@@ -645,6 +647,7 @@ const LRU_CACHE = {
645 } 647 }
646} 648}
647 649
650const RESUMABLE_UPLOAD_DIRECTORY = join(CONFIG.STORAGE.TMP_DIR, 'resumable-uploads')
648const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls') 651const HLS_STREAMING_PLAYLIST_DIRECTORY = join(CONFIG.STORAGE.STREAMING_PLAYLISTS_DIR, 'hls')
649const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls') 652const HLS_REDUNDANCY_DIRECTORY = join(CONFIG.STORAGE.REDUNDANCY_DIR, 'hls')
650 653
@@ -699,7 +702,8 @@ const CUSTOM_HTML_TAG_COMMENTS = {
699 TITLE: '<!-- title tag -->', 702 TITLE: '<!-- title tag -->',
700 DESCRIPTION: '<!-- description tag -->', 703 DESCRIPTION: '<!-- description tag -->',
701 CUSTOM_CSS: '<!-- custom css tag -->', 704 CUSTOM_CSS: '<!-- custom css tag -->',
702 META_TAGS: '<!-- meta tags -->' 705 META_TAGS: '<!-- meta tags -->',
706 SERVER_CONFIG: '<!-- server config -->'
703} 707}
704 708
705// --------------------------------------------------------------------------- 709// ---------------------------------------------------------------------------
@@ -819,6 +823,7 @@ export {
819 PEERTUBE_VERSION, 823 PEERTUBE_VERSION,
820 LAZY_STATIC_PATHS, 824 LAZY_STATIC_PATHS,
821 SEARCH_INDEX, 825 SEARCH_INDEX,
826 RESUMABLE_UPLOAD_DIRECTORY,
822 HLS_REDUNDANCY_DIRECTORY, 827 HLS_REDUNDANCY_DIRECTORY,
823 P2P_MEDIA_LOADER_PEER_VERSION, 828 P2P_MEDIA_LOADER_PEER_VERSION,
824 ACTOR_IMAGES_SIZE, 829 ACTOR_IMAGES_SIZE,
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index edf12bc41..38e7a76d0 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -2,6 +2,9 @@ import { QueryTypes, Transaction } from 'sequelize'
2import { Sequelize as SequelizeTypescript } from 'sequelize-typescript' 2import { Sequelize as SequelizeTypescript } from 'sequelize-typescript'
3import { TrackerModel } from '@server/models/server/tracker' 3import { TrackerModel } from '@server/models/server/tracker'
4import { VideoTrackerModel } from '@server/models/server/video-tracker' 4import { VideoTrackerModel } from '@server/models/server/video-tracker'
5import { UserModel } from '@server/models/user/user'
6import { UserNotificationModel } from '@server/models/user/user-notification'
7import { UserVideoHistoryModel } from '@server/models/user/user-video-history'
5import { isTestInstance } from '../helpers/core-utils' 8import { isTestInstance } from '../helpers/core-utils'
6import { logger } from '../helpers/logger' 9import { logger } from '../helpers/logger'
7import { AbuseModel } from '../models/abuse/abuse' 10import { AbuseModel } from '../models/abuse/abuse'
@@ -11,13 +14,9 @@ import { VideoCommentAbuseModel } from '../models/abuse/video-comment-abuse'
11import { AccountModel } from '../models/account/account' 14import { AccountModel } from '../models/account/account'
12import { AccountBlocklistModel } from '../models/account/account-blocklist' 15import { AccountBlocklistModel } from '../models/account/account-blocklist'
13import { AccountVideoRateModel } from '../models/account/account-video-rate' 16import { AccountVideoRateModel } from '../models/account/account-video-rate'
14import { ActorImageModel } from '../models/account/actor-image' 17import { ActorModel } from '../models/actor/actor'
15import { UserModel } from '../models/account/user' 18import { ActorFollowModel } from '../models/actor/actor-follow'
16import { UserNotificationModel } from '../models/account/user-notification' 19import { ActorImageModel } from '../models/actor/actor-image'
17import { UserNotificationSettingModel } from '../models/account/user-notification-setting'
18import { UserVideoHistoryModel } from '../models/account/user-video-history'
19import { ActorModel } from '../models/activitypub/actor'
20import { ActorFollowModel } from '../models/activitypub/actor-follow'
21import { ApplicationModel } from '../models/application/application' 20import { ApplicationModel } from '../models/application/application'
22import { OAuthClientModel } from '../models/oauth/oauth-client' 21import { OAuthClientModel } from '../models/oauth/oauth-client'
23import { OAuthTokenModel } from '../models/oauth/oauth-token' 22import { OAuthTokenModel } from '../models/oauth/oauth-token'
@@ -25,6 +24,7 @@ import { VideoRedundancyModel } from '../models/redundancy/video-redundancy'
25import { PluginModel } from '../models/server/plugin' 24import { PluginModel } from '../models/server/plugin'
26import { ServerModel } from '../models/server/server' 25import { ServerModel } from '../models/server/server'
27import { ServerBlocklistModel } from '../models/server/server-blocklist' 26import { ServerBlocklistModel } from '../models/server/server-blocklist'
27import { UserNotificationSettingModel } from '../models/user/user-notification-setting'
28import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update' 28import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update'
29import { TagModel } from '../models/video/tag' 29import { TagModel } from '../models/video/tag'
30import { ThumbnailModel } from '../models/video/thumbnail' 30import { ThumbnailModel } from '../models/video/thumbnail'
@@ -44,6 +44,7 @@ import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-pla
44import { VideoTagModel } from '../models/video/video-tag' 44import { VideoTagModel } from '../models/video/video-tag'
45import { VideoViewModel } from '../models/video/video-view' 45import { VideoViewModel } from '../models/video/video-view'
46import { CONFIG } from './config' 46import { CONFIG } from './config'
47import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
47 48
48require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string 49require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string
49 50
@@ -141,7 +142,8 @@ async function initDatabaseModels (silent: boolean) {
141 ThumbnailModel, 142 ThumbnailModel,
142 TrackerModel, 143 TrackerModel,
143 VideoTrackerModel, 144 VideoTrackerModel,
144 PluginModel 145 PluginModel,
146 ActorCustomPageModel
145 ]) 147 ])
146 148
147 // Check extensions exist in the database 149 // Check extensions exist in the database
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index cb58454cb..676f88653 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -2,11 +2,11 @@ import * as passwordGenerator from 'password-generator'
2import { UserRole } from '../../shared' 2import { UserRole } from '../../shared'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' 4import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user'
5import { UserModel } from '../models/account/user' 5import { UserModel } from '../models/user/user'
6import { ApplicationModel } from '../models/application/application' 6import { ApplicationModel } from '../models/application/application'
7import { OAuthClientModel } from '../models/oauth/oauth-client' 7import { OAuthClientModel } from '../models/oauth/oauth-client'
8import { applicationExist, clientsExist, usersExist } from './checker-after-init' 8import { applicationExist, clientsExist, usersExist } from './checker-after-init'
9import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants' 9import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants'
10import { sequelizeTypescript } from './database' 10import { sequelizeTypescript } from './database'
11import { ensureDir, remove } from 'fs-extra' 11import { ensureDir, remove } from 'fs-extra'
12import { CONFIG } from './config' 12import { CONFIG } from './config'
@@ -79,6 +79,9 @@ function createDirectoriesIfNotExist () {
79 // Playlist directories 79 // Playlist directories
80 tasks.push(ensureDir(HLS_STREAMING_PLAYLIST_DIRECTORY)) 80 tasks.push(ensureDir(HLS_STREAMING_PLAYLIST_DIRECTORY))
81 81
82 // Resumable upload directory
83 tasks.push(ensureDir(RESUMABLE_UPLOAD_DIRECTORY))
84
82 return Promise.all(tasks) 85 return Promise.all(tasks)
83} 86}
84 87
diff --git a/server/initializers/migrations/0645-actor-remote-creation-date.ts b/server/initializers/migrations/0645-actor-remote-creation-date.ts
new file mode 100644
index 000000000..38b3b881c
--- /dev/null
+++ b/server/initializers/migrations/0645-actor-remote-creation-date.ts
@@ -0,0 +1,26 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7 db: any
8}): Promise<void> {
9 {
10 const data = {
11 type: Sequelize.DATE,
12 defaultValue: null,
13 allowNull: true
14 }
15 await utils.queryInterface.addColumn('actor', 'remoteCreatedAt', data)
16 }
17}
18
19function down (options) {
20 throw new Error('Not implemented.')
21}
22
23export {
24 up,
25 down
26}
diff --git a/server/initializers/migrations/0650-actor-custom-pages.ts b/server/initializers/migrations/0650-actor-custom-pages.ts
new file mode 100644
index 000000000..1338327e8
--- /dev/null
+++ b/server/initializers/migrations/0650-actor-custom-pages.ts
@@ -0,0 +1,33 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7 db: any
8}): Promise<void> {
9 {
10 const query = `
11 CREATE TABLE IF NOT EXISTS "actorCustomPage" (
12 "id" serial,
13 "content" TEXT,
14 "type" varchar(255) NOT NULL,
15 "actorId" integer NOT NULL REFERENCES "actor" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
16 "createdAt" timestamp WITH time zone NOT NULL,
17 "updatedAt" timestamp WITH time zone NOT NULL,
18 PRIMARY KEY ("id")
19 );
20 `
21
22 await utils.sequelize.query(query)
23 }
24}
25
26function down (options) {
27 throw new Error('Not implemented.')
28}
29
30export {
31 up,
32 down
33}