diff options
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/checker.ts | 14 | ||||
-rw-r--r-- | server/initializers/constants.ts | 5 | ||||
-rw-r--r-- | server/initializers/installer.ts | 10 |
3 files changed, 23 insertions, 6 deletions
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts index b69188f7e..317d59423 100644 --- a/server/initializers/checker.ts +++ b/server/initializers/checker.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as config from 'config' | 1 | import * as config from 'config' |
2 | |||
3 | import { promisify0 } from '../helpers/core-utils' | 2 | import { promisify0 } from '../helpers/core-utils' |
4 | import { OAuthClientModel } from '../models/oauth/oauth-client-interface' | ||
5 | import { UserModel } from '../models/account/user-interface' | 3 | import { UserModel } from '../models/account/user-interface' |
4 | import { ApplicationModel } from '../models/application/application-interface' | ||
5 | import { OAuthClientModel } from '../models/oauth/oauth-client-interface' | ||
6 | 6 | ||
7 | // Some checks on configuration files | 7 | // Some checks on configuration files |
8 | function checkConfig () { | 8 | function checkConfig () { |
@@ -70,6 +70,13 @@ async function usersExist (User: UserModel) { | |||
70 | return totalUsers !== 0 | 70 | return totalUsers !== 0 |
71 | } | 71 | } |
72 | 72 | ||
73 | // We get db by param to not import it in this file (import orders) | ||
74 | async function applicationExist (Application: ApplicationModel) { | ||
75 | const totalApplication = await Application.countTotal() | ||
76 | |||
77 | return totalApplication !== 0 | ||
78 | } | ||
79 | |||
73 | // --------------------------------------------------------------------------- | 80 | // --------------------------------------------------------------------------- |
74 | 81 | ||
75 | export { | 82 | export { |
@@ -77,5 +84,6 @@ export { | |||
77 | checkFFmpeg, | 84 | checkFFmpeg, |
78 | checkMissedConfig, | 85 | checkMissedConfig, |
79 | clientsExist, | 86 | clientsExist, |
80 | usersExist | 87 | usersExist, |
88 | applicationExist | ||
81 | } | 89 | } |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index e27d011fa..4a49c1ab3 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -226,6 +226,9 @@ const FRIEND_SCORE = { | |||
226 | MAX: 1000 | 226 | MAX: 1000 |
227 | } | 227 | } |
228 | 228 | ||
229 | const SERVER_ACCOUNT_NAME = 'peertube' | ||
230 | const ACTIVITY_PUB_ACCEPT_HEADER = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' | ||
231 | |||
229 | const ACTIVITY_PUB = { | 232 | const ACTIVITY_PUB = { |
230 | COLLECTION_ITEMS_PER_PAGE: 10, | 233 | COLLECTION_ITEMS_PER_PAGE: 10, |
231 | VIDEO_URL_MIME_TYPES: [ | 234 | VIDEO_URL_MIME_TYPES: [ |
@@ -352,8 +355,10 @@ export { | |||
352 | PODS_SCORE, | 355 | PODS_SCORE, |
353 | PREVIEWS_SIZE, | 356 | PREVIEWS_SIZE, |
354 | REMOTE_SCHEME, | 357 | REMOTE_SCHEME, |
358 | ACTIVITY_PUB_ACCEPT_HEADER, | ||
355 | FOLLOW_STATES, | 359 | FOLLOW_STATES, |
356 | SEARCHABLE_COLUMNS, | 360 | SEARCHABLE_COLUMNS, |
361 | SERVER_ACCOUNT_NAME, | ||
357 | PRIVATE_RSA_KEY_SIZE, | 362 | PRIVATE_RSA_KEY_SIZE, |
358 | SORTABLE_COLUMNS, | 363 | SORTABLE_COLUMNS, |
359 | STATIC_MAX_AGE, | 364 | STATIC_MAX_AGE, |
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 5221b81a5..c3521a9e4 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -3,8 +3,8 @@ import { UserRole } from '../../shared' | |||
3 | import { logger, mkdirpPromise, rimrafPromise } from '../helpers' | 3 | import { logger, mkdirpPromise, rimrafPromise } from '../helpers' |
4 | import { createUserAccountAndChannel } from '../lib' | 4 | import { createUserAccountAndChannel } from '../lib' |
5 | import { createLocalAccount } from '../lib/user' | 5 | import { createLocalAccount } from '../lib/user' |
6 | import { clientsExist, usersExist } from './checker' | 6 | import { applicationExist, clientsExist, usersExist } from './checker' |
7 | import { CACHE, CONFIG, LAST_MIGRATION_VERSION } from './constants' | 7 | import { CACHE, CONFIG, LAST_MIGRATION_VERSION, SERVER_ACCOUNT_NAME } from './constants' |
8 | 8 | ||
9 | import { database as db } from './database' | 9 | import { database as db } from './database' |
10 | 10 | ||
@@ -128,9 +128,13 @@ async function createOAuthAdminIfNotExist () { | |||
128 | } | 128 | } |
129 | 129 | ||
130 | async function createApplicationIfNotExist () { | 130 | async function createApplicationIfNotExist () { |
131 | const exist = await applicationExist(db.Application) | ||
132 | // Nothing to do, application already exist | ||
133 | if (exist === true) return undefined | ||
134 | |||
131 | logger.info('Creating Application table.') | 135 | logger.info('Creating Application table.') |
132 | const applicationInstance = await db.Application.create({ migrationVersion: LAST_MIGRATION_VERSION }) | 136 | const applicationInstance = await db.Application.create({ migrationVersion: LAST_MIGRATION_VERSION }) |
133 | 137 | ||
134 | logger.info('Creating application account.') | 138 | logger.info('Creating application account.') |
135 | return createLocalAccount('peertube', null, applicationInstance.id, undefined) | 139 | return createLocalAccount(SERVER_ACCOUNT_NAME, null, applicationInstance.id, undefined) |
136 | } | 140 | } |